find and replace with php

They have: 45 posts

Joined: Oct 2001

Let's say, for example, i have a set of strings, and one of them is like:

hahahaha haha
hahaha more haha
hahahaha haha
hahaha more haha

Basically, I want to get replace all of the with , except it has to be that, and it also has to get rid of the ending . And it has to include the closing tag.

Hopefully this was clear enough. Thanks for any help you may offer!

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

<?php
$text
= preg_replace(\"#<font size=\\"3\\">(.*)</font>#iU\", \"<p class=\\"whatever\\">\\\\1</p>\", $text);
?>
PHP Docs: preg_replace(), Pattern Modifiers

Mark Hensler
If there is no answer on Google, then there is no question.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.