Re: Re: Clean break.

From: Date: Fri, 31 Jul 2009 22:37:56 +0000
Subject: Re: Re: Clean break.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-296152@lists.php.net to get a copy of this message
I was trying to stay away from regex as much as possible due to the overhead? I might be wrong here. This script will be parsing a lot of requests/sec. Thousands, maybe more, which it also needs to toss into a DB. I want to try and keep it as fast as possible. This is tricky when you don't know what you are doing :). My coding is limited to hammering away at the search box on php.net until I get a push in the right direction. It's just a hack from there. Using phpster's substr suggestion has already sped this up considerably. 2009/7/31 Ollisso <ollisso@fromru.com>: > On Sat, 01 Aug 2009 00:22:21 +0300, Paul Halliday <paul.halliday@gmail.com> > wrote: > >> Whats the cleanest (I have a really ugly) way to break this: >> >> [21/Jul/2009:00:00:47 -0300] >> >> into: >> >> date=21/jul/2009 >> time=00:00:47 >> > ... > Why not just use regexp ? > > For example: > > $string = "long text.. multiply lines... >        [21/Jul/2009:00:00:47 -0300] > >        [ 1/Jul/2009:00:00:47 -0300] > >        [22/Jul/2009:00:00:47 -0300]"; > > > preg_match_all('#\[([ 0-9a-zA-Z/]+):([0-9:]+) > [^]]+\]#',$string,$matches,PREG_SET_ORDER); > > print_r($matches); > > Output: > Array > ( >    [0] => Array >        ( >            [0] => [21/Jul/2009:00:00:47 -0300] >            [1] => 21/Jul/2009 >            [2] => 00:00:47 >        ) > >    [1] => Array >        ( >            [0] => [ 1/Jul/2009:00:00:47 -0300] >            [1] =>  1/Jul/2009 >            [2] => 00:00:47 >        ) > >    [2] => Array >        ( >            [0] => [22/Jul/2009:00:00:47 -0300] >            [1] => 22/Jul/2009 >            [2] => 00:00:47 >        ) > > ) > > > -- > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#296152) next »