Re: Breaking up data efficiently -- closed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

Thanks for all the input. Really an eye opener on all the various ways
that could do the same thing! :) Really appreciate it.

Off to work with new ideas!

Tom Rogers wrote:
> function build($data){
>   global $path;
>   $i = count($path);
>   $path[$i]['location'] = $data[1];
>   $path[$i]['country'] = $data[2];
>   $path[$i]['datetime'] = $data[3];
> }
> $path = array();
> $str = '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';
> preg_replace_callback('/(\w+),\s*(\w+),\s([0-9-]+\s[0-9:]+)(?=\|)/s','build',$str);
> print_r($path);


Jasper Bryant-Greene wrote:
> $itinerary = explode('|', $booking->booking_flight_details);
> 
> foreach($itinerary as $item) {
> 	$item = explode(',', $item);
> 	$path[] = array(
> 		'location'	=> $item[0],
> 		'country'	=> $item[1],
> 		'datetime'	=> $item[2]
> 	);
> }


Philip Hallstrom wrote:
> $bits = split("[|,]", $booking->booking_flight_details);
> $size = count($itenary);
> for ( $i = 0; $i < $size; $i += 3 ) {
>     $path[$i]['location'] = $bits[$i];
>     $path[$i]['country'] = $bits[$i + 1];
>     $path[$i]['datetime']  = $bits[$i + 2];
> }
> 




-- 
Wee Keat Chin

Protocol Networks
p: 1300 131 932
e: weekeat@xxxxxxxxx
h: www.pn.com.au

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux