Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove <img ???

Status
Not open for further replies.

Zeroanarchy

Technical User
Jun 11, 2001
630
AU
Hi was wondering if someone might be able to help, I have the following code

$content = "<table><tr><td>This is a general description or some usual text that I want to display.</td><td><img src=' alt='Logo' width='50' height='50' /></td></tr></table>";

what I am trying to do is remove elements of it so all that is left is the written description. I know I can do a replace for the <table> <td> <tr> to removes those, but I am unsure as to how I can remove the img section of the above value?? The issue is that the img part will vary it will not always be the same.

Cheers
zeroanarchy

[afro]ZeroAnarchy
Experience is a wonderful thing. It enables you to recognize a mistake
when you make it again.
 
this is a good use for a regular expression

Code:
$search = '/<img.*?>/i';
$replace = '';
$content = "<table><tr><td>This is a general description or some usual text that I want to display.</td><td><img src='[URL unfurl="true"]http://www.test.com.au//images/logos/client_1100_200.gif'[/URL] alt='Logo' width='50' height='50' /></td></tr></table>";
$output = preg_replace ($search, $replace, $content);
 
Thanks jpadie for you help I'll give a go.

Cheers


[afro]ZeroAnarchy
Experience is a wonderful thing. It enables you to recognize a mistake
when you make it again.

 
Thanks jpadie that worked really well one last question.

If the code was as follows
Code:
&lt;b&gt;20.06.2008&lt;/b&gt;
					&lt;br&gt;
					&lt;b&gt;Location: Sydney - West&lt;/b&gt;
					&lt;br&gt;
					&lt;b&gt;Recruiter: Link Recruitment Group Pty Ltd&lt;/b&gt;
					&lt;br&gt;

Is there away of removing everything left of the word 'Location:'?

Cheers

[afro]ZeroAnarchy
Experience is a wonderful thing. It enables you to recognize a mistake
when you make it again.

 
yes
Use strpos to locate the word and then substr to grab0the rest of the string
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top