Forum Moderators: coopster
This works, but would a regexp be faster, and if so, what would it be? I'm stuck...
$kw = str_replace("0","",$kw);
$kw = str_replace("1","",$kw);
$kw = str_replace("2","",$kw);
$kw = str_replace("3","",$kw);
$kw = str_replace("4","",$kw);
$kw = str_replace("5","",$kw);
$kw = str_replace("6","",$kw);
$kw = str_replace("7","",$kw);
$kw = str_replace("8","",$kw);
$kw = str_replace("9","",$kw);
$kw = str_replace("()","",$kw);
$kw = str_replace("@","",$kw);
$kw = str_replace("(,)","",$kw);
$kw = str_replace("\n","",$kw);
would a regexp be faster
To really find out, you need to run Apache Bench or some such thing on a small test script (many iterations) to find out. Getting the regex engin going may or may not be faster. That said,
- do you have huge bandwidth on this page?
- is this part of the script a bottleneck?
I would use the regex and then go back and optimize, especially trying to get DB queries more efficient.
Tom