Forums

Formatting When Using get_post_custom_values To Return Multiple Values (2 posts)

  1. Hood Web Mgmt Web Design
    Member
    Posted 1 year ago #

    I have a custom field titled 'internet' which has multiple items in a checkbox format. I'm using the following code in my theme to return the values of the field:

    <li><span style="font-weight:bold;">Internet:</span> <?php $internet_values = get_post_custom_values('internet'); foreach ( $internet_values as $key => $value ) { echo "$value, "; } ?></li>

    This code returns the following formatting:

    Internet: Wi-Fi, DSL,

    I'd like to only return the comma space in between values rather than after each value. In other words, I don't want the comma space returned after DSL, only between each value. Could anyone suggest a way to do this?

    Thanks in advance for your assistance! My PHP level is intermediate at best and I have trouble implementing code off the top of my head.

  2. Hood Web Mgmt Web Design
    Member
    Posted 1 year ago #

    Woops, the code actually returns the following format:

    Wi-Fi, DSL, Cable,

    And I'd like it to return the following format:

    Wi-Fi, DSL, Cable

    The difference being the lack of comma after the last value returned. Hope that's a slightly clearer explanation.

Topic Closed

This topic has been closed to new replies.

About this Topic