Newbie regexp

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

Post Reply
Bison
Forum Newbie
Posts: 4
Joined: Fri Mar 05, 2004 7:36 pm

Newbie regexp

Post by Bison »

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.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

$string = str_replace('<body bgcolor="#ffffff">', '', $string);
Bison
Forum Newbie
Posts: 4
Joined: Fri Mar 05, 2004 7:36 pm

Post by Bison »

I have tried that, but "<body bgcolor="#ffffff">" isn't removed.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

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 »

Here as well. I had a spelling mistake. Sorry.
Post Reply