在PHP中获取字符串的第一行 [英] Obtain first line of a string in PHP
本文介绍了在PHP中获取字符串的第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在PHP 5.3中,似乎有一个很好的函数我想要什么:
In PHP 5.3 there is a nice function that seems to do what I want:
strstr(input,"\n",true)
不幸的是,服务器运行PHP 5.2.17,并且可选的第三个参数strstr
不可用.有没有一种方法可以在以前的版本中一行实现?
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?
推荐答案
您要去的地方
$str = strtok($input, "\n");
这篇关于在PHP中获取字符串的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文