- var_dump: documentation ( source)
- array_merge: documentation ( source)
- explode: documentation ( source)
<?php
function thing(array $needle, $haystack) {
$haystack = array($haystack);
foreach ($needle as $a) {
$target = [];
foreach ($haystack as $h) {
$target = array_merge($target, explode($a, $h));
}
$haystack = $target;
}
return $array_filter($haystack) + $needle;
}
var_dump(thing(array('THIS', 'test', 'hello', 'A', 'is'), 'helloTHISisAblindtest'));