The perl code : if ($query) { while ($query =~ /\s/) { $query =~ s/\s//g; } }
How to change it to php code?
I think the perl could be written with just : $query =~ s/\s+//s;
the php equiv would be: $query = preg_replace( "/\s+/", "", $query );
hth stew
Thx!!!
One new problem following:
If I want to parse " php is good programming language "
to
"php is good programming language"
Any suggestion? I am very new in php...
Check out the trim() function.
stew
oops, After looking at the source of this page and seeing the original string that would be:
$string = trim( preg_replace( "/\s+/", " ", $string ));