Hi, hope this is the right place,

Here is my problem

<h4 Bla Bla Bla Bla Bla Bla
Bla Bla Bla Bla Bla
Bla Bla Bla Bla Bla Bla
Bla Bla Bla Bla </h4>

I want the content between <h4> tags in a variable, using only one expressions

thnx
Kusal

you can try this one:

$reg = '/<h4>(.+)<\/h4>/';

hope this helps.

Using ryan_vietnow's pattern, you can get the string between <h4> and </h4>.

<?php
$x="<h4>blah blah blah</h4>";
$reg = '/<h4>(.+)<\/h4>/';
preg_match($reg,$x,$matches);
print $matches[0];
?>

If you wanna learn more bout regular expression, Here is the video tutorial.

P.S. ryan_vietnow, thanks. I was scratching my head over the same thing for sometime now !

No this works only for one line I need to get content in multiple lines, as I given in the example.

<h4 Bla Bla Bla Bla Bla Bla
Bla Bla Bla Bla Bla
Bla Bla Bla Bla Bla Bla
Bla Bla Bla Bla </h4>

Aren't you saving this in a variable or something ?

<h4><font color="#FFFF00">CALVARY BAPTIST CHURCH, 334-585-6455<br>
310 DOTHAN ROAD, ABBEVILLE AL 36310</font></h4>

this is a sample what i want,

$data = file_get_contents($url);
all is in $data

<?php
$reg = '/<h4>(.*)<\/h4>/s';
$data="<h4><font color=\"#FFFF00\">CALVARY BAPTIST CHURCH, 334-585-6455<br>
310 DOTHAN ROAD, ABBEVILLE AL 36310</font></h4>";
preg_match($reg,$data,$matches);
print $matches[1];
?>

Phew! finally. I hope this works.

Hey thnx!!!! it works, thnx

you are welcome!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.