Loading ...
Sorry, an error occurred while loading the content.

working with data from other websites

Expand Messages
  • pannet1
    Dear Code Gurus, // program to get a web page from www and then particular words // declare the file handle $file_handle =
    Message 1 of 1 , Jul 5 11:03 AM
    • 0 Attachment
      Dear Code Gurus,

      <code>
      // program to get a web page from www and then particular words

      // declare the file handle
      $file_handle =
      fopen("http://www.example.com/dynamic.asp?var1=val1&var2=val2", "r");

      // while until the end of file is reached
      while (!feof($file_handle)) {

      // dump the file contents after stripping tags to a string
      $sDump = fgetss($file_handle);

      // cleanString is my own function to remove unwanted
      // characters using a series of str_replace function with
      // empty string.
      $sTracking = CleanString($sDump);

      print $sTracking; // outputs contains over 3000 characters
      // in a single line. so far it is ok.

      // my objective is to get all characters starting from
      // 2873 till the end of the string.

      $sMyObjective = substr($sTracking, 2873); // this never
      works as my string contains several individual sentences, so
      substr($sTracking, 2) actually removes first two letters of several of
      these sentences

      // convert the string to array to see what is the problem
      $aTracking = (array) $sTracking;
      print_r($aTracking);
      }
      fclose($file_handle); // closes while and file
      </code>

      print $sTracking was commented out for this purpose. some of the
      print_r output is only given below for brevity.

      <output>
      Array ( [0] => ) Array ( [0] => ) Array ( [0] => ) Array ( [0] => )
      Array ( [0] => ) Array ( [0] => ) Array ( [0] => ) Array ( [0] => )
      Array ( [0] => ) some string Array ( [0] => even longer strings are
      here Array ( [0] => and even more ..
      </output>

      can you help me by letting me know how to handle this kind of string
      produced by fgetts() ?

      my objective
      -------------
      to get all characters starting from 2873 till the end of the string.

      Thanks in anticipation.

      regards
    Your message has been successfully submitted and would be delivered to recipients shortly.