|
Posted by Bocah Sableng on 04/18/07 12:03
On Apr 18, 2:57 pm, Chris Jones <chris...@gmail.com> wrote:
> $eid = $_GET['EID'];
> $href = str_replace("{$eid}","{$eid}",db_result($qry,0,"href");
>
Beware of case-sensitive behaviour of str_replace. Perhaps you should
replace str_replace() with str_ireplace() or just change the variable
name to uppercase. And dollar sign inside double quotes replaced with
its variable value.
$href = str_ireplace("{$eid}", $eid, db_result($qry,0,"href");
or
$href = str_replace("{\$EID}", $eid, db_result($qry,0,"href");
For a better approach, consider using preg_replace() with pattern like
"/\{\\\$EID\}/". Because preg_replace() can accept array as parameter,
so you can replace multiple variables in single step.
Another method is using preg_replace_callback() with reusable callback
function.
HTH
[Back to original message]
|