For example, I have such array:
$someArray = Array (
[stationList] => Array (
[0] => Array (
[stationName] => A.S.Peta Bypass
[stationId] => -1 )
[1] => Array (
[stationName] => Aala
[stationId] => -1 )
)
)
Now U want to display the array elements(stationName) in a dropdown list in php, I used the below code:
<select id="txtLabourId">
<option selected="selected">Choose one</option>
<?php
foreach($someArray as $name) { ?>
<option value="<?php echo $name['stationName'] ?>"><?php echo $name['stationName'] ?></option>
<?php
} ?>
</select>
But its giving the error:
Undefined index stationName on line 222
How to resolve this? Any help appreciated.