How to echo out the values individually of this array?
Array ( [0] => 20120514 [1] => My Event 3 )
so
echo $value[0]; etc
I have this so far:
foreach (json_decode($json_data_string, true) as $item) {
$eventDate = trim($item['date']);
// positive limit
$myarray = (explode(',', $eventDate, 2));
foreach ($myarray as $value) {
echo $value;
}
This echo's out the whole string no as an array. and if i do this?
echo $value[0};
Then i only get 2 characters of it??
EDIT:
The print_r :
Array ( [0] => 20120430 [1] => My Event 1 )
Thanks
Chris
you need the set key and value in foreach loop for that:
this should do the trick :)
The problem here is in your explode statement
Try changing your initial $item['date'] to be 2012,04,30 if that's what you're trying to do. Otherwise I'm not entirely sure what you're trying to print.
Here is a simple routine for an array of primitive elements: