Stupid language. You apparently don't need to define the $results before using it, assuming the examples are correct.
Anyway, if you haven't already done it, here's a modified version of the original code segment I posted:
php code: else if ( strpos($thing,"logged in") )
{
$time = "[" . substr($thing, 11, 5) . "]";
preg_match( '/(?<=\[INFO\] )\S+/' , $thing , $results );
$person = $results[0];
$chats[] = $time.' <i>Joined:</i> <b>'.htmlspecialchars($person).'</b>';
}
else if ( strpos($thing,"lost connection") )
{
$time = "[" . substr($thing, 11, 5) . "]";
preg_match( '/(?<=\[INFO\] )\S+/' , $thing , $results );
$person = $results[0];
$reason = trim(substr(strrchr($thing, '.'), 1));
$chats[] = $time.' <i>Disconnected:</i> <b>'.htmlspecialchars($person).'</b> ('.$reason.')';
}
I also added a trim() call around the $reason value, to remove the space that appeared. |