Monkuar Posted August 11, 2012 Share Posted August 11, 2012 Okay, so my json data is: {"items":[null,{"id":"2","type":"m"},{"id":"1","type":"m"}]} $data = json_decode($_POST['itemid']); var_dump($data); foreach ($data as $name => $value) { foreach ($value as $entry) { $items[] = $entry->id; } } echo 'Here is a list of item id\'s sir!: <br><br> '.implode(",", $items).' </b>'; But for some odd reason it is showing: ,2,1 instead of just 2,1 is it because it's under 2 for eaches? I tried to remove the first foreach, but get stuck... anyone wanna help? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/266944-help-get-rid-of-this-stupid-comma-_/ Share on other sites More sharing options...
Monkuar Posted August 11, 2012 Author Share Posted August 11, 2012 if it's null it re-literates and counts it as a foreach, f my life, fixed it my self lol stupid me, thanks all Link to comment https://forums.phpfreaks.com/topic/266944-help-get-rid-of-this-stupid-comma-_/#findComment-1368594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.