Mark Jones
Mark Jones

Reputation: 115

Json_Decode With a int as a name

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.

Upvotes: 1

Views: 94

Answers (1)

Andriy F.
Andriy F.

Reputation: 2537

Try

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

In case of echo:

echo $a->properties->geometry->coordinates->{0} . "\n";

Upvotes: 1

Related Questions