making certain text variables....?

Help
Anonymous
2004-03-07
2004-03-31
  • Anonymous - 2004-03-07

    Lets just say for example i want to retrieve the "Searching 4,285,199,774 web pages" text from the bottom of http://www.google.com

    Then process it like this:
    number="4,285,199,774"

    Is something like this possible?

     
    • Anonymous - 2004-03-13

      Yes its actualyl quite easy with PHP.
      Use the string functions of PHP [strpos(), substr(), trim() etc]

      Some untested[!!!] code:
      ------------------------------------
      $pos = strpos($mydata[0], "Searching");
      $mydata[0] = substr($mydata[0], $pos+10);
      $pos2 = strpos($mydata[0], "web pages");
      $mydata[0] = substr($mydata[0], 0, $pos2);
      $mydata[0] = trim($mydata[0]);
      ------------------------------------
      $mydata[0] should now contain the number of searched pages.

      Use the function list from PHP.net for details and other string-functions

       
    • Denzo

      Denzo - 2004-03-31

      Or try this and say $all is google's main page content.

      preg_match('/Searching (.*?) web pages/si', $all, $search);
      $number = $search[1];

      $number should now contain the data you want. (Untested aswell.) This code is maybe a bit easier to use and understand.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks