You can use regular expressions to emulate the behavior of LIKE
in PHP:
<?php
function like($needle, $haystack)
{
$regex = '/' . str_replace('%', '.*?', $needle) . '/';
return preg_match($regex, $haystack) > 0;
}
var_dump(like('rod%', 'rodrigorigotti')); // bool(true)
var_dump(like('%tti', 'rodrigorigotti')); // bool(true)
var_dump(like('%gori%', 'rodrigorigotti')); // bool(true)
var_dump(like('%lala', 'rodrigorigotti')); // bool(false)
var_dump(like('lala%', 'rodrigorigotti')); // bool(false)
var_dump(like('%lala%', 'rodrigorigotti')); // bool(false)
"equal" or "has"?
– user28595