I'm having some difficulty functioning this morning! This isn't specifically WP (more PHP), but I think that it would benefit WP devs in the future, so I'm asking here. I'm trying to create a list that does something like this:
$items = get_post_meta($post->ID, "item-specific-meta");
$output = '';
foreach ($items as $item){
$item_id = $item[#] <--I WANT THIS TO BE A NUMBER
$output .= '<label for="item-';
$output .= $item_id;
$output .= '"><input id="item-';
$output .= $item_id;
$output .= '"/>';
$output .= $item;
$output .= '</label>';
}
Which would return something like:
<label for="item-1">
<input id="item-1"/>
Item 1
</label>
Right now I'm putting the content of the custom meta item in place of the numbered list that I would prefer using. It does the job, but I just don't like all that excess crap that could be done simply.
Like I opened with, my brain isn't working right this morning and I can't even think of the proper search term to Google and answer this myself, so I'm turning to the awesome folks here! Thanks in advance!