Reply to Re[2]: [PHP] Breaking up data efficiently

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация