Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getCombinations($array) {
- //initalize array
- $results = [[]];
- //get all combinations
- foreach ($array as $k => $element) {
- foreach ($results as $combination){
- $results[] = $combination + [$k => $element];}
- }
- //return filtered array
- return array_values(array_filter($results));
- }
- function prima($str,$haystack){
- if ($str != '')
- {
- if (count($haystack)>0)
- {
- $a = array();
- for($i=0; $i<count($haystack);$i++)
- {
- if (stripos($str, $haystack[$i]) !== false)
- {
- array_push($a,$haystack[$i]);
- }
- //var_dump($haystack[$i]);
- }
- if (count($a) > 3)
- {
- $arr = getCombinations($a);
- for($j=0; $j<count($arr); $j++)
- {
- if (implode('',$arr[$j]) === $str)
- {
- print implode(';',$arr[$j]). "<br />";
- }
- }
- }
- else print implode(';',$a). "<br />";
- }
- }
- }
- $regex = array('pro', 'gram', 'program', 'programmer', 'merit','it');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement