I wrote this, but I can't understand how it works. This is the code:
public function extractHostname($rawOutput) {
$start = strpos($rawOutput, '@')+1;
print $start."\n";
$end = strpos($rawOutput, ' ');
print $end."\n";
print $end-strlen($rawOutput)."\n";
return strtolower(substr($rawOutput, $start, $end-strlen($rawOutput)));
}
Sample input:
:Kulverstukas!Geek@whore.house PRIVMSG #test :!yes
So, $start is 19, $end is 30, $end-strlen() is -22. substr gets everything from position 19 to -22 and it gets it correctly.
What the hell is going on?