Skip to content
Advertisement

Tag: newline

Obtain first line of a string in PHP

In PHP 5.3 there is a nice function that seems to do what I want: 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? Answer For the relatively short texts, where lines could be delimited by either one (“n”) or

PHP Linefeeds (n) Not Working

For some reason I can’t use n to create a linefeed when outputting to a file with PHP. It just writes “n” to the file. I’ve tried using “\n” as well, where it just writes “n” (as expected). But I can’t for the life of me figure out why adding n to my strings isn’t creating new lines. I’ve also

Advertisement