Need help getting text between tags

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Baquanb@yahoo.com

    #1

    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($tex t);

    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>

  • Andy C.

    #2
    Re: Need help getting text between tags

    Baquanb@yahoo.c om wrote:[color=blue]
    > 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($tex t);
    >
    > echo $text;
    >
    > }
    >[/color]

    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">tex t</font>)

    Comment

    • Baquanb@yahoo.com

      #3
      Re: Need help getting text between tags

      Never mind I found a way to do it

      Comment

      • Geoff Berrow

        #4
        Re: Need help getting text between tags

        Message-ID: <1145999322.896 240.317100@i39g 2000cwa.googleg roups.com> from
        Baquanb@yahoo.c om contained the following:
        [color=blue]
        >I need to get some text between font tags[/color]
        <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/

        Comment

        Working...