Hi, I wrote a function that cuts a string from the beginning till the first newline.
My question is: is there a faster way to do this using preg_replace?
Thanks,
IGOR
/**
Returns the string from the beginning to the first newline.
This function is platform-independent.
*/
function strings_until_first_newline($s) {
$pos = strpos($s, "\015");
if ($pos > 0)
$s = substr($s, 0, $pos);
$pos = strpos($s, "\012");
if ($pos > 0)
$s = substr($s, 0, $pos);
return $s;
}