rich w
April 23rd, 2006, 09:06
Hey to all,
Got a simple problem here.
I'm trying to read stuff in from a text file..it looks like this:
//PROCESSOR
bla bla bla bla
bla bla bla
//MEMORY
bla bla bla ba
Basically I want to be able to return all the data for the processor:
//PROCESSOR([^<>]*)//
Now that kind of works...except it returns all the processor data and everything beyond that. It's not detecting that next //
Here is the code if anyone wants to play:
<?php
function getinfo($url,$stat) {
$handle = fopen($url, "rb");
$contents = "";
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
$regs = Array ();
if (eregi("//$stat([^<>]*)//", $contents, $regs)) {
$info = $regs[1];
}
fclose($handle);
return $info;
}
echo getinfo("http://hyperion.universalns.com/raw-info.php",PROCESSOR);
?>
Can anyone help?
Cheers
Got a simple problem here.
I'm trying to read stuff in from a text file..it looks like this:
//PROCESSOR
bla bla bla bla
bla bla bla
//MEMORY
bla bla bla ba
Basically I want to be able to return all the data for the processor:
//PROCESSOR([^<>]*)//
Now that kind of works...except it returns all the processor data and everything beyond that. It's not detecting that next //
Here is the code if anyone wants to play:
<?php
function getinfo($url,$stat) {
$handle = fopen($url, "rb");
$contents = "";
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
$regs = Array ();
if (eregi("//$stat([^<>]*)//", $contents, $regs)) {
$info = $regs[1];
}
fclose($handle);
return $info;
}
echo getinfo("http://hyperion.universalns.com/raw-info.php",PROCESSOR);
?>
Can anyone help?
Cheers