Results 1 to 8 of 8

Thread: Help using preg_match to get number of pages (of <a href="javascript: GotoPage(4);" .

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Help using preg_match to get number of pages (of <a href="javascript: GotoPage(4);" .

    Hi all i am trying to use preg_match to get number of pages from a html that has this format :

    of <a href="javascript: GotoPage(4);" class="pagingLink">4</a>

    in this case i want to grab the number 4 but it never works. Could any one tell me what i am doing wrong ?Hope some one help me .Thanks




    PHP Code:

    global $curl;

    // Retrieve number of pages page.
        
    echo 'Checking friends list... ';
        
    curl_setopt($curlCURLOPT_URL'./test.html');
        
    curl_setopt($curlCURLOPT_POST0);
        
    $result curl_exec($curl);
        
    $headers curl_getinfo($curl);
        
        
    // Find out how many pages there are. 
        
    if (preg_match('~of <a href="(.+?)" class="pagingLink">([0-9]+)</a>~'$result$matches))
        {
            
    $pages $matches[2];
                echo 
    ' Number of pages: $pages ';
            unset(
    $matches);
            
        } 
    Html content :
    HTML Code:
    of <a href="javascript: GotoPage(4);" class="pagingLink">4</a>
    Last edited by tony007; Jun 15th, 2008 at 06:35 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width