Page 1 of 1

str_replace problem

Posted: Sat Sep 29, 2007 5:37 am
by itsmani1
i am trying to replace "<?" but its not working here is code:

Code: Select all

$desc="<?";
$filter=array("<?php","\<?","\?>","javascript","script");
$filtered_desc = str_replace($filter, "", $desc);
echo $filtered_desc;
any way?

thanks

Posted: Sat Sep 29, 2007 8:15 am
by volka
test data
expected results
actual result
?

this works

Posted: Sat Sep 29, 2007 8:34 am
by yacahuma
this works for me

Code: Select all

$str = "<?php javascript echo \"hello\";?>";
$data = str_replace(array('<?php','javascript','<?','?>'),'', $str);
echo $data;