Jump to content

Preg_Match not working


skwap

Recommended Posts

Hello Dear,

 

i want to get the text value (bla bla bla) from the below string.

 

$string = "<div class="on"> <p>bla bla bla</p></div>";

 

my code is

 

$desc_pattern = '/\<div class=\"on\"><p>(.*)<\/p><\/div>/s';
preg_match($desc_pattern,$string,$new_desc);
print_r($new_desc);

 

 

but its only showing

 

Array ( )

 

please help me

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/254067-preg_match-not-working/
Share on other sites

not working...

 

actually the source code is

 

<div class="on">

 

                  <p>There is a dream car for you.

<br>

<br>Try the free version of Asphalt 5 and race with the fastest dream cars ever created by some of the most prestigious manufacturers in the world.

<br>Everything you’ve ever dreamed of doing behind the wheel is here!

<br>Stop dreaming and get in!</p>

 

                  </div>

 

conside the above is as string & make a pattern

 

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.