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 Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.