Mysqli_real_escape_string阻止preg_split工作?

Example Text: This will be stored in the $_POST['x'] variable
This is sentence one.
This is sentence two.
This is sentence three.

If I run this code below It will return an array with only one element

$x= mysqli_real_escape_string($db, $_POST['x']);
$y= preg_split("/(
|
|)/", $x);

But if I run this code below it will split it correctly into all 3 elements.

$x = $_POST['x'];
$y= preg_split("/(
|
|)/", $x);

Has anyone else experienced this phenomenon? Why does it happen?

http://php.net/mysqli-real-escape-string
Characters encoded are NUL (ASCII 0), , , \, ', ", and Control-Z.

This means newlines become \ (LF), \ (CR) and \\ (CRLF). Therefore they no longer match the regex.

In future, RTM ;)