Get String From Page

A little PHP function to extract an unknown string with only the beginning and end of the string. Works well for parsing a page and finding a file name.

e.g-

GetString ('google.com', 'http://', '.css');
function GetString ($URL, $str_start, $str_end) {
if ($stream = fopen($URL, 'r')) {
$test_str = stream_get_contents($stream);
$n = strlen($str_end);
return substr($test_str, strpos($test_str, $str_start),
strpos($test_str, $str_end)-strpos($test_str, $str_start)+$n);
fclose($stream);
}}

One Response to “Get String From Page”

  1. Mick says:

    Thanks for the code, works well.

Leave a Reply