|
Posted by Tom Rogers on 06/28/05 03:47
Hi,
Tuesday, June 28, 2005, 10:26:12 AM, you wrote:
TR> This ay work:
TR> <?
TR> $str = 'Melbourne, AU, 21-07-2005 14:00:00|Perth, AU,
TR> 21-07-2005 18:00:00|Perth, AU, 25-07-2005 14:00:00|Melbourne, AU,
TR> 25-07-2005 18:00:00';
TR> preg_match_all('/(\w+),\s*(\w+),\s*([0-9-]+)\s([0-9:]+)(?=\|)/s',$str,$match);
TR> print_r($match);
A different way that will generate what you actually need :)
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);
--
regards,
Tom
[Back to original message]
|