Should I remove whitespace or what?

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
Citizen
Forum Contributor
Posts: 300
Joined: Wed Jul 20, 2005 10:23 am

Should I remove whitespace or what?

Post by Citizen »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Basically I'm working with a CMS that has the entire html input in a single variable, and I need to remove this bunch of html depending on a variable:

[syntax="html"]				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				Main page for the members area.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				View your personal homepage.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				You can design / edit your personal webpage and edit your site account settings.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				View all your messages that have been sent to you.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />

				Submit all of your items in this area including pictures to blogs and much more.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				Edit all of your items you have added on the site.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				View all of the info on your friends that are in your network.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				View all of the favorites that you have added to your list.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				View all of the bulletins posted by your friends.
			
					
				<img src="http://www.bmxpo.com/151/file/style/konsort/a1.gif" alt="" style="vertical-align:middle;" />
				Invite your friends to come and join us.
Here's my code that I tried, but didn't work:[/syntax]

Code: Select all

$patterns[] = '/<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				Main page for the members area.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				View your personal homepage.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				You can design \/ edit your personal webpage and edit your site account settings.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				View all your messages that have been sent to you.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>

				Submit all of your items in this area including pictures to blogs and much more.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				Edit all of your items you have added on the site.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				View all of the info on your friends that are in your network.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				View all of the favorites that you have added to your list.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				View all of the bulletins posted by your friends.
			
					
				<img src="(.*?)a1.gif" alt="" style="vertical-align:middle;" \/>
				Invite your friends to come and join us./';
$replacements[] = '';


$sHtml = preg_replace($patterns, $replacements, $sHtml);
Also, I had to (.*?) the domain part out so that it could work on more than just the one domain.

Any ideas?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Post by Jonah Bron »

Well, I'd say try it. Gotta start somewhere.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

What exactly are you trying to do? Retrieve the domain names from the images?

Code: Select all

$text = preg_replace('/img src="(.+?)"/im', 'whatever', $text);
echo $text;
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply