468,249 Members | 1,448 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Need help getting text between tags

I need to get some text between font tags but I only need the text in
the last table. The code i'm using below will get text between all font
tags anyone know how I can just get whats in TABLE3 font tags.

$url = "http://www.mysite.com";
$data = implode("", file($url));
preg_match_all ("/<td>([^`]*?)<\/td>/", $data, $matches);

foreach ($matches[0] as $match) {

preg_match ("/<font>([^`]*?)&nbsp;<\/font>/", $match, $temp);
$text = $temp['1'];
$text= strip_tags($text);

echo $text;

}

TABLE1
<table>
<td>
<font>text1</font>
<b>something</b>
</td>
<td>
<font>text2</font>
<b>something</b>
</td>
<td>
<font>text3</font>
<b>something</b>
</td>
</table>

TABLE2
<table>
<td>
<font>text4</font>
<b>something</b>
</td>
<td>
<font>text5</font>
<b>something</b>
</td>
<td>
<font>text6</font>
<b>something</b>
</td>
</table>

TABLE3
<table>
<td>
<font>text7</font>
<b>something</b>
</td>
<td>
<font>text8</font>
<b>something</b>
</td>
<td>
<font>text9</font>
<b>something</b>
</td>
<td>
<font>text10</font>
<b>something</b>
</td>
</table>

Apr 25 '06 #1
3 3545
Ba*****@yahoo.com wrote:
I need to get some text between font tags but I only need the text in
the last table. The code i'm using below will get text between all font
tags anyone know how I can just get whats in TABLE3 font tags.

$url = "http://www.mysite.com";
$data = implode("", file($url));
preg_match_all ("/<td>([^`]*?)<\/td>/", $data, $matches);

foreach ($matches[0] as $match) {

preg_match ("/<font>([^`]*?)&nbsp;<\/font>/", $match, $temp);
$text = $temp['1'];
$text= strip_tags($text);

echo $text;

}


One posibility is to give the font tags a css id or class then just
include that in your preg_match statement. If table code is php
generated then think about id'ing each font tage based on what table
its in (i.e. <font id="table2">text</font>)

Apr 25 '06 #2
Never mind I found a way to do it

Apr 26 '06 #3
Message-ID: <11**********************@i39g2000cwa.googlegroups .com> from
Ba*****@yahoo.com contained the following:
I need to get some text between font tags

<pedant>
<font> is deprecated
</pedant>
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Apr 26 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by dan glenn | last post: by
6 posts views Thread by Pete | last post: by
1 post views Thread by sommarlov | last post: by
7 posts views Thread by ojsimon | last post: by
reply views Thread by Dale | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.