我有一个表值如下字符串:
最佳答案
一种方法是将传入的字符串拆分为单独的地址,然后检查它们是否均与表值匹配:
$string = 'PhysicalAddress:E8-6A-64-DE-48-60PhysicalAddress:04-EA-56-08-E6-8EPhysicalAddress:04-EA-56-08-E6-8FPhysicalAddress:06-EA-56-08-E6-8EPhysicalAddress:04-EA-56-08-E6-92';
$components = str_split($string, 33);
$query = "SELECT *
FROM table1
WHERE preview LIKE '%" . implode("%'\n AND preview LIKE '%", $components) . "%'";
echo $query;
输出:
SELECT *
FROM table1
WHERE preview LIKE '%PhysicalAddress:E8-6A-64-DE-48-60%'
AND preview LIKE '%PhysicalAddress:04-EA-56-08-E6-8E%'
AND preview LIKE '%PhysicalAddress:04-EA-56-08-E6-8F%'
AND preview LIKE '%PhysicalAddress:06-EA-56-08-E6-8E%'
AND preview LIKE '%PhysicalAddress:04-EA-56-08-E6-92%'
Demo on 3v4l.org
关于php - 如何将一个字符串与另一个字符串值完全匹配?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57619729/