substr_count无法使用新行吗? [英] substr_count not working with new lines?
本文介绍了substr_count无法使用新行吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这让我发疯,它一直返回0
This is driving me nuts, it keeps returning 0
substr_count('df
d
fd
f
df', '\n');
如果我使用像"d"这样的字母,它会正常工作
if I use a letter like "d", it works fine
substr_count('df
d
fd
f
df', 'd');
任何人都可以对此有所了解吗?
Can anyone shed some light on this?
谢谢
推荐答案
您需要对控制字符使用双引号:
You need to use double quotes for control characters:
var_dump(substr_count('df
d
fd
f
df', "\n"));
这篇关于substr_count无法使用新行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文