Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question preg_match_all pattern question #2

    i really do not understand this.
    this should be extremely simple yet it is not working...

    i have this text:

    PHP Code:
    $text '
    <td>
       <%test1%>
       <%test2%>
    </td>

    <td>
       <%test3%>
       <%test4%>
       <%test5%>
    </td>
    '

    and i want to split it into two arrays. both the contents of the insides of the <td></td>.

    patterns i have tried:
    PHP Code:
    $pattern "/<td>(.*)<\/td>/";
    $pattern "/\<td\>(.*)\<\/td\>/"
    and then:
    PHP Code:
    preg_match_all($pattern,$text,$return);
    var_dump($return); 
    and that will always return an empty array... i dont understand why.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Try this for your pattern.
    PHP Code:
    $pattern "/<td.*?>.*?<\/td>/xmsi"
    That will catch td cells that also have ids or classes on them.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am getting stuck with similar problem. Say if I have many table rows like the followings

    <tr title="abc"><td>...</td></tr>
    <tr title="def"><td>...</td></tr>
    <tr title="def"><td>...</td></tr>

    How can I extract on those tr with title = "abc"?

    Thanks for any help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •