Re: Regular Expressions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The replaced string is returned by the function. This works.

$str = "test test2";
$str2 = preg_replace('/ /', ',', $str);

If your are doing simple replacements like this you should use
str_replace() it's much faster!

$str = "test test2";
$str2 = str_replace(' ', ',', $str);

- Frank
> How do I use preg_replace to replace a space (" ") with a comma (",")?
> 
> i am using:
> 
> preg_replace('/ /', ',', $string).
> 
> this isn't working.
> 
> 
> --
> Gerardo S. Rojas
> mailto: grojas@strategicinc.com
> 
> 

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux