How do i loop through this array. I’ve tried the foreach statement with wierd results. I need to access the values for StopName and Time.
Thanks in advance
Array
(
[Direction0] => Array
(
[0] => Array
(
[DirectionNum] => 0
[EndTime] => 2012-11-26T06:16:00
[RouteID] => 87v1
[StartTime] => 2012-11-26T05:51:00
[StopTimes] => Array
(
[0] => Array
(
[StopID] => 3002573
[StopName] => GREENBELT STATION + BUS BAY C
[StopSeq] => 1
[Time] => 2012-11-26T05:51:00
)
[1] => Array
(
[StopID] => 3002579
[StopName] => GREENBELT METRO DRIVE + CHERRYWOOD
[StopSeq] => 6
[Time] => 2012-11-26T05:52:26
)
[2] => Array
(
[StopID] => 3002409
[StopName] => CHERRYWOOD LA + IVY LA
[StopSeq] => 8
[Time] => 2012-11-26T05:53:31
)
[3] => Array
(
[StopID] => 3002413
[StopName] => CHERRYWOOD LA + US COURT HOUSE
[StopSeq] => 10
[Time] => 2012-11-26T05:54:00
)
[4] => Array
(
[StopID] => 3002910
[StopName] => POWDER MILL RD + #161
[StopSeq] => 20
[Time] => 2012-11-26T05:57:35
)
This code was originally in the form of a json object and i used the php json_decode function which translated this data into a multi-demensional array. Hope my question is clear enough to provide insight or solution.
Given your array is called
$array, you can just do the following: