How to iterate through PHP array This is the output of var_export
array (
0 =>
array (
'place' => 'GreenPepper',
'Distance' => '0.487',
'Lat' => '8.52699',
'Lng' => '76.92419100000006',
),
1 =>
array (
'place' => 'BAKE \'N\' COOL',
'Distance' => '0.513',
'Lat' => '8.527908',
'Lng' => '76.92643599999997',
),
)
PHP
for ($row = 0; $row < sizeof($obj); $row++) {
echo $value[$row][place];
}
It the suppossed output was GreenPepper0.487
but instead it was getting this
<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Use of undefined constant place - assumed 'place' in C:\wamp\www\SortJson.php on line <i>28</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0010</td><td bgcolor='#eeeeec' align='right'>246592</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\SortJson.php' bgcolor='#eeeeec'>..\SortJson.php<b>:</b>0</td></tr>
</table></font>
<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Use of undefined constant Distance - assumed 'Distance' in C:\wamp\www\SortJson.php on line <i>28</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0010</td><td bgcolor='#eeeeec' align='right'>246592</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\SortJson.php' bgcolor='#eeeeec'>..\SortJson.php<b>:</b>0</td></tr>
</table></font>
GreenPepper0.487<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Use of undefined constant place - assumed 'place' in C:\wamp\www\SortJson.php on line <i>28</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0010</td><td bgcolor='#eeeeec' align='right'>246592</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\SortJson.php' bgcolor='#eeeeec'>..\SortJson.php<b>:</b>0</td></tr>
</table></font>
<br />
<font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Use of undefined constant Distance - assumed 'Distance' in C:\wamp\www\SortJson.php on line <i>28</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0010</td><td bgcolor='#eeeeec' align='right'>246592</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\SortJson.php' bgcolor='#eeeeec'>..\SortJson.php<b>:</b>0</td></tr>
</table></font>
EDIT
The cause was a typo
echo $value[$row]['place'];
instead of this echo $value[$row][place];
solved the issue