Dave Davis
Dave Davis

Reputation: 574

Why is PHP_EOL not working when nl2br works fine

I copy the following string from a web page:

Reservation No.:    218662
Play Date:  Saturday - 4/11/2020
Course:     Truman  352-750-2374

I want to break on CRLF and create three lines in my array. There is a CRLF (0D 0A) after 2374 and 2020

I have tried

$lines = explode ("/n",$this->reservation);
$lines = explode ("/r/n",$this->reservation);
$lines = explode ("chr(10)",$this->reservation);
$lines = explode (chr(13.chr(10),$this->reservation);
$lines = explode (PHP_EOL,$this->reservation);

and nothing works.

However nl2br does display the string properly.

So, it seems the nl2br is recognizing the line breaks in the source string but explode is not.

What am I missing? Thanks.

Upvotes: 0

Views: 162

Answers (0)

Related Questions