i've read on web page, explaining in php must faster execution loop foreach. new me, test himself. how convert foreach loop in php? using 1 below example:
foreach ($station->items->item $trips=>$trip) { $ny_trips[$trips] = $trip; }
i've seen loops in php, not using 'as' in them. i'm not sure how above in php loop. require doing count() of $station->items->item? thanks!
assuimg keys on array perfect numerical sequence starting @ 0 looking for.
for($x = 0, $nitems = count($station->items->item); $x<$nitems; $x++) { $ny_trips[$x] = $station->items->item[$x]; }
if keys non-numeric or not in perfect order need this.
$keys = array_keys($station->items->item); for($x = 0, $nitems = count($station->items->item);$x < $nitems; $x++) { $ny_trips[$keys[$x]] = $station->items->item[$keys[$x]]; }
Comments
Post a Comment