1

ok, so I have a Huge JSON feed,
And all is working well. Exept, one of the key

Curently I am doing

$json=file_get_contents($source);
$data = json_decode($json,true);
foreach($data->items->features as $a){
   echo "{$a->properties->tpegMessage->generation_time_pretty}\n";
   echo '<br />';
   echo "{$a->properties->tpegMessage->title}\n";
   echo '<br />';
   echo "{$a->properties->geometry->coordinates->1}\n";
   echo '<br />';
   echo "{$a->properties->geometry->coordinates->0}\n";
   echo '<br />';   echo '<br />';   echo '<br />';   echo '<br />';   echo '<br />';
}

Now the key issue is with

''$a->properties->geometry->coordinates->0''

As php wont retrave the JSON value with the 0 or 1 name

the values are typicaly floats, value to a lat or long.

Mark Jones
  • 115
  • 8
  • 7
    Maybe this http://stackoverflow.com/questions/3240532/how-can-i-access-an-object-attribute-that-starts-with-a-number or this http://stackoverflow.com/questions/3851489/return-php-object-by-index-number-not-name – Fabien Sa Jan 11 '13 at 13:31
  • Cheers This is exacly what I needed :) – Mark Jones Jan 11 '13 at 13:44

1 Answers1

1

Try

$a->properties->geometry->coordinates->{0}

In case of echo:

echo $a->properties->geometry->coordinates->{0} . "\n";
Andriy F.
  • 2,467
  • 1
  • 25
  • 23