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
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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.