...

View Full Version : string problem



graziano
11-29-2006, 08:17 AM
Hello

I have a big $text_log variable containing this

value1 value2 value3 -value4-
value1 value2 value3 -value4-
value1 value2 value3 -value4-
....
....
value1 value2 value3 -value4-
value1 value2 value3 -value4-


I need to replace the 1th "-" of each line with nothing ""
and the last "-" of each line with a space " ".
Only in this way I could explode $text correctly for my array
usage .

How to do ?

I tried with str_replace , without success .

Any idea how can do that ?

Thank you

chump2877
11-29-2006, 09:56 AM
you could quickly do this regular expressions.

something like:


$text_log = preg_replace('/(-)(\w+)(-)/','$2 ',$text_log);

kaisellgren
11-29-2006, 10:01 AM
$text_log = preg_replace("/(-)(.+?)(-)/","\\2 ",$text_log);

graziano
11-29-2006, 12:22 PM
Thank You



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum