Reply to Re: [PHP] Replacement Question.

Your name:

Reply:


Posted by Richard Lynch on 04/22/05 13:12

On Wed, April 20, 2005 7:22 am, Bob Palma said:
> I have a database field that I need to read and do some conversion on.
> Here is what the raw data from the database looks like:
>
> --
> 1084751309jpenaDisney Vignette Fleximon disk utilization
> alert C:\ at 85%1084799703bpalmafixed.1084799713bpalmaclosed
> --
>
> After conversion, it should look like this:
>
> --
> 5/16/2004 7:48:29 PM jpena
> Disney Vignette Fleximon disk utilization alert C:\ at 85%
>
> 5/17/2004 9:15:03 AM bpalma
> fixed.
>
> 5/17/2004 9:15:13 AM bpalma
> closed
> --
>
>
> I have tried to use eregi_replace to convert the timestamps to DateTime,
> but I end up with all three timestamps being changed to the same time
> (5/16/2004 7:48:29 PM).
>
> Here is the quick, albeit ugly, code I've tried to come close
>
> --
> $worklogt3 = eregi_replace("","<br>", $worklogt1);
> $worklogt4 = eregi_replace("","<br><br>", $worklogt3);
> $worklog = eregi_replace("[0-9]{10,10}",date("m/j/y g:i
> a",$worklogt4),$worklogt4);
> --
>
> $worklogt1 is the value of the field from the database and the first two
> replacements are actually for different characters, even though they
> look the same.
>
> Can anyone help me with this? I've been beating myself up for almost
> three days over this.

Your problem is that you are passing in all of $worklogt4 to the date
function, and that *BEGINS* with the first date/time, and that's what PHP
uses.

You need to FIRST break up your single line into separeate lines, based on
the 10-digit time-stamps.

Something like:
$lines = split('[0-9]{10,10}', $worklogt4);

But then I'm not sure you get to keep the date/time -- I never use split
much, myself...

--
Like Music?
http://l-i-e.com/artists.htm

[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

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