使用php从数组中查找字符串中出现的所有单词
$input='myntralove.com' 我有一个数组 $array=array('my','myntra','love','myntralove'); 我的预期产出是: 我的 明特拉 爱 网站使用php从数组中查找字符串中出现的所有单词,php,arrays,string,file,Php,Arrays,String,File,$input='myntralove.com' 我有一个数组 $array=array('my','myntra','love','myntralove'); 我的预期产出是: 我的 明特拉 爱 网站 你能从test.txt文件中发布一个示例行吗?你能从test.txt文件中发布一个示例行吗? <?php $mystring = 'cheapestbricks.com.au'; $findmes = ['cheapest','bricks']; $array = explode("\
你能从test.txt
文件中发布一个示例行吗?你能从test.txt
文件中发布一个示例行吗?
<?php
$mystring = 'cheapestbricks.com.au';
$findmes = ['cheapest','bricks'];
$array = explode("\n", file_get_contents('test.txt'));
foreach($array as $findme) {
$pos = strpos($mystring, trim($findme));
if ($pos === false) {
//echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo $findme.'<br/>';
}
}