Wee Keat wrote:
> /***** BEGIN DATA *****/
> 
> Melbourne, AU, 21-07-2005 14:00:00|Perth, AU, 21-07-2005 18:00:00|Perth,
> AU, 25-07-2005 14:00:00|Melbourne, AU, 25-07-2005 18:00:00
> 
> /***** END DATA *****/
> [snip]
> /***** BEGIN CODE *****/
> $itenary = explode('|', $booking->booking_flight_details);
>                       
> $size = count($itenary);
> 
> for($i=0; $i < $size; $i++) {
>     list($path[$i]['location'],
>          $path[$i]['country'],
>          $path[$i]['datetime']) = explode(',', $itenary[$i]);
> }
> /***** END CODE *****/
> 
> *Question*: Is the above the code an effective way to do it? Or is there
> a better/faster way?

It's pretty good, but I would've done:

$itinerary = explode('|', $booking->booking_flight_details);

foreach($itinerary as $item) {
        $item = explode(',', $item);
        $path[] = array(
                'location'      => $item[0],
                'country'       => $item[1],
                'datetime'      => $item[2]
        );
}

That's really just a matter of preference though.

Jasper

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to