Obtain first line of a string in PHP

后端 未结 11 1121
醉话见心
醉话见心 2021-02-01 13:14

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

11条回答
  •  走了就别回头了
    2021-02-01 13:59

    $first_line = substr($fulltext, 0, strpos($fulltext, "\n"));
    

    or something thereabouts would do the trick. Ugly, but workable.

提交回复
热议问题