I am using an API call that returns an array. It's an array not a sting. I want to wrap the array in an unordered list. I need two separate lists.
1) I want to wrap everything (including sub arrays) in an unordered list.
<ul>
<li>[name]</li>
<li>[name]</li>
<li>[name]</li>
</ul>
2) I just want to wrap [name] in an unordered list.
<ul>
<li>[1347037874]</li>
<ul>
<li>[level_id]</li>
<li>[name]</li>
<li>[canceled]</li>
<li>[cancelDate]</li>
<li>and all the rest</li>
</ul>
<li>[1347037874]</li>
<ul>
<li>[level_id]</li>
<li>[name]</li>
<li>[canceled]</li>
<li>[cancelDate]</li>
<li>and all the rest</li>
</ul>
</ul>
I assign the API call like this:
$member_id = $logged_in_WP_user_id;
$member_levels = member_levels($member_id);
For explanation only (this line is not in my function...when I output $member_levels like this: htmlspecialchars(print_r(get_member($member_id),true))
I get the following:
Array
(
[1347037874] => stdClass Object
(
[Level_ID] => 1347037874
[Name] => HFM-Cardiac Resistance Training Program
[Cancelled] =>
[CancelDate] =>
[Pending] =>
[UnConfirmed] =>
[Expired] =>
[ExpiryDate] =>
[Active] => 1
[Status] => Array
(
[0] => Active
)
[Timestamp] => 1349804951
[TxnID] => WL-2-1347037874
)
[1347037875] => stdClass Object
(
[Level_ID] => 1347037875
[Name] => HFM-Official Heart Health Guide
[Cancelled] =>
[CancelDate] =>
[Pending] =>
[UnConfirmed] =>
[Expired] =>
[ExpiryDate] =>
[Active] => 1
[Status] => Array
(
[0] => Active
)
[Timestamp] => 1349804951
[TxnID] => WL-2-1347037875
)
)
I have tried several ways to wrap the array in an array, it get close but still can make it work right.
Tks!
p.s. here is what I am now using to make the first list but how do I get the other key values to display as in unordered list under the key value =>Name.
$member_levels = ember_levels($member_id);
$output = '';
$output .= '<ul>';
foreach($member_levels as $level) {
$output .= '<li>' . $level_array[]=$level->Name . '</li>';
}
$output .= '</ul>';
print_r($output);