Removing a paragraph

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
mklynx
Forum Newbie
Posts: 1
Joined: Thu Nov 25, 2010 10:23 am

Removing a paragraph

Post by mklynx »

Hi all

I am having a problem. I do not have any code to show you for this problem because everything i tried did not work.
My problem is the following. I have a string with a lot of text in it. I do not know what text is in it. I receive it dynamically.
I do know it is build up in paragraphs that are separated with <br/>. The problem is that i do not need all paragraphs.
I need to remove the paragraphs where there are reverences to web sites. like HTTP://www.bla.tv.

I know how to do it in a language that most of you will not know and that is TACL.
You search for the string (http...) get the position of that.
Then you look for the first occurrence of <br/> before the position and look for the first occurrence of <br/> after the position.
Then you delete the part between the two positions you got.

But i do not have enough PHP experience to get this done.
I can get the position of the first search (http...) but then i am stuck how to get the second and third position.

Marcel Koert
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Removing a paragraph

Post by josh »

strpos is the PHP equivalent for finding the positions of text. But I'd recommend regular expressions language (which can be used with the PHP function preg_replace)
Post Reply