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

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

Reply via email to