Alex Rivera | Logout

Obtain first line of a string in PHP

Asked 2012-02-01T14:39:46.250
53

In PHP 5.3 there is a nice function that seems to do what I want:

strstr(input,"\n",true)

Unfortunately, the server runs PHP 5.2.17 and the optional third parameter of strstr is not available. Is there a way to achieve this in previous versions in one line?

Edit
Report

1 Answer

1

try this:

substr($text, 0, strpos($text, chr(10)))
answered 2012-02-01T14:44:38.523

Your Answer