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
Bison
Forum Newbie
Posts: 4 Joined: Fri Mar 05, 2004 7:36 pm
Post
by Bison » Fri Mar 05, 2004 7:36 pm
Hi,
How do I write the search pattern for the str_replace function in order to replace the string
"<body bgcolor="#ffffff">" with ""?
Thanks in advance.
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Fri Mar 05, 2004 7:46 pm
$string = str_replace('<body bgcolor="#ffffff">', '', $string);
Bison
Forum Newbie
Posts: 4 Joined: Fri Mar 05, 2004 7:36 pm
Post
by Bison » Fri Mar 05, 2004 8:01 pm
I have tried that, but "<body bgcolor="#ffffff">" isn't removed.
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Fri Mar 05, 2004 8:08 pm
Works fine here. Eg
Code: Select all
<?php
$string = 'foo bar <body bgcolor="#ffffff"> flibble';
$string = str_replace('<body bgcolor="#ffffff">', '', $string);
echo $string;
?>
Maybe you should post an example of your code?
Bison
Forum Newbie
Posts: 4 Joined: Fri Mar 05, 2004 7:36 pm
Post
by Bison » Fri Mar 05, 2004 8:25 pm
Here as well. I had a spelling mistake. Sorry.