- assert: documentation ( source)
- strpos: documentation ( source)
- preg_replace: documentation ( source)
<?php
function match($haystack, $needle) {
return strpos($haystack, $needle) !== FALSE;
}
function remove($haystack, $needle) {
return preg_replace("/{$needle}/", "", $needle) !== FALSE;
}
assert(remove("test string", "test") == " string");
assert(remove("string test test string", " test ") == "stringtest string");