PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Sat Sep 29, 2007 5:37 am
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
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Sat Sep 29, 2007 8:15 am
test data
expected results
actual result
?
yacahuma
Forum Regular
Posts: 870 Joined: Sun Jul 01, 2007 7:11 am
Post
by yacahuma » Sat Sep 29, 2007 8:34 am
this works for me
Code: Select all
$str = "<?php javascript echo \"hello\";?>";
$data = str_replace(array('<?php','javascript','<?','?>'),'', $str);
echo $data;