add string return option to gethttpsocketfile()

This commit is contained in:
Miles Lott 2002-03-30 16:32:08 +00:00
parent bef6b7ed7b
commit 87f3a8e6b8

View File

@ -177,8 +177,13 @@
}
}
// return contents of a web url as an array or false if timeout
function gethttpsocketfile($file)
/*
Return contents of a web url as an array or false if timeout.
If $string is set (True), a string is returned with all \r and \n removed.
This allows for parsing of xml where the formatting was not ideal (elements
opened and closed on a single line).
*/
function gethttpsocketfile($file,$string=False)
{
$server = str_replace('http://','',$file);
$file = strstr($server,'/');
@ -198,7 +203,16 @@
{
break;
}
if($string)
{
$line = ereg_replace("\n",'',$line);
$line = ereg_replace("\r",'',$line);
$lines .= $line;
}
else
{
$lines[] = $line;
}
$i++;
}
$this->close_port();
@ -218,9 +232,18 @@
return 0;
}
while($line = $this->read_port())
{
if($string)
{
$line = ereg_replace("\n",'',$line);
$line = ereg_replace("\r",'',$line);
$lines .= $line;
}
else
{
$lines[] = $line;
}
}
$this->close_port();
return $lines;
}