List Info

Thread: working with data from other websites




working with data from other websites
user name
2008-07-05 13:05:51

Dear Code Gurus,

<code&gt;
// 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&quot;, "r&quot;);

// 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

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )