Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 php 中,如何打开和读取文本文件并在数组中创建字符串类型的每一行和一个元素?
然后我的计划是使用 aforeach遍历数组并使用in_array()在文件内容中查找单词。
foreach
in_array()
使用file():
file()
$lines = file('path/to/file'); foreach($lines as $line) { //enjoy }