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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts

    is there a way of finding if a html page has a certain format?

    I want to do one thing if the html page contains

    PHP Code:
    <span class="tel">Tel:  021 4929850 </span
    and another thing if the html page contains

    PHP Code:
    <span class="tel">Tel:  021 4929850 </span>
                                    
                                    
                                        <
    span class="tel2">Tel087 9870805</span
    Im using the file_get_contents(); funtion to get the html code..

  • #2
    New Coder
    Join Date
    Nov 2009
    Location
    Australia
    Posts
    78
    Thanks
    0
    Thanked 7 Times in 7 Posts
    Here's a start

    PHP Code:
    preg_match_all('/<span class="(.*)">Tel: 087 9870805<\/span>/Uis'$html$matches,PREG_SET_ORDER);
    print_r($matches); 
    your matches are stored in $matches , just loop in $matches to find "tel2" and do your stuff, etc...


  •  

    Posting Permissions

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