[SOLVED] preg_replace
Posted: Fri Nov 26, 2004 1:04 pm
Ok, I'm in a hurry - to write this, so try to do my best in a few words (without sample code)
I take a string from a textfield (POST method) and use this function to replace all 2 letter and shorter words with "" - nothing, just need to kill them.
It works fine, but only every second value is replaced,
change 2 letter word into ---
Output:
--- 12 --- 12 --- 12 --- 12 --- 12 --- etc...
I added \s vefore and after the $pattern, but is\t still doesn't work.
There was only one solution I made working, but it takes CPU resources,
that is to preg_replace every \s with " " - two blanks.
I tried for $i = 0;, $i < 1000000; $i++)
{
do replace
}
but on the 1000001 word it fail's
Anyone knows of better ways ?
Thanks Ahead !!!!
I take a string from a textfield (POST method) and use this function to replace all 2 letter and shorter words with "" - nothing, just need to kill them.
It works fine, but only every second value is replaced,
change 2 letter word into ---
Output:
--- 12 --- 12 --- 12 --- 12 --- 12 --- etc...
I added \s vefore and after the $pattern, but is\t still doesn't work.
There was only one solution I made working, but it takes CPU resources,
that is to preg_replace every \s with " " - two blanks.
I tried for $i = 0;, $i < 1000000; $i++)
{
do replace
}
but on the 1000001 word it fail's
Anyone knows of better ways ?
Thanks Ahead !!!!