我目前有一个问题。我有一个如下所示的代码,我想要一个运算符来检查查询的一部分是否存在于数组中。这是我的代码:PHP运营商,看看是否有东西的一部分
<?php
$search = 'party hat';
$query = ucwords($search);
$string = file_get_contents('http://clubpenguincheatsnow.com/tools/newitemdatabase/items.php');
$string = explode('<br>',$string);
foreach($string as $row)
{
preg_match('/^(\D+)\s=\s(\d+)\s=\s(\D+)\s=\s(\d+)/', trim($row), $matches);
if($matches[1] == "$query")
{
echo "<a href='http://clubpenguincheatsnow.com/tools/newitemdatabase/info.php?id=$matches[2]'>";
echo $matches[1];
echo "</a><br>";
}
}
?>
我想要做的是,而不是if($matches[1] == "$query")
检查,如果两者是一致的,我希望我的代码,看是否$query
一部分在$matches[1]
存在。我该怎么做?请帮帮我!
你需要更具体一点:每个字符串都有存在于所有其他字符串的一部分。例如,'XX'中两个X之间的空字符串可以在'ABC'中的'A'之前找到。 – Joni