Jump to content

Help with preg_match() function


jjmusicpro

Recommended Posts

I have this in the html:

 

<div class="c"><strong>Joes Cool Name</strong></div>

 

I am trying to use preg_match to just get "Joes Cool Name" out of it, but keep getting blank values...

Here is what I have..thanks for any help guys... im new to preg_match function :)

 

preg_match('/<div class=\"c\">([^\<]*)<\/div>/i', $result, $name);

Link to comment
https://forums.phpfreaks.com/topic/221053-help-with-preg_match-function/
Share on other sites

Ok cool, here is one i tried doing myself, but having same problems.

 

HTML -

<div class="mfsm">Email:</div></td><td valign="top"><div class="mfsm"><a href="mailto:Array">[email protected]</a></div>

 

Here is what i have, but its blank..

preg_match('|mail([^\<]*)<\/div><\/td><td valign=\"top\"><div class=\"mfsm\">([^\<]*)<|', $result, $email);

So if i have <div class="mfsm">Email:</div></td><td valign="top"><div class="mfsm"><a href="mailto:Array">[email protected]</a></div>

 

I want it to give me anything within the <div class="mfsm"></div>

 

Now sometimes there might be an image in there like <div class="mfsm"><img src="/something/joe.jpg"></div> so i want that full thing "<img src="/something/joe.jpg">" thats what my reg exp tried to do before.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.