3v4l.org

run code in 300+ PHP versions simultaneously
<?php $words = ["apple", "sample", "app", "justappgg", "тоҷик", "отабек", "баҳодурбек", "APELCIN", "API", "pap"]; mb_internal_encoding("UTF-8"); $items = [ "api", "ppal", "ap", "papp" ]; foreach ($items as $item) { foreach ($words as $word) { $wordSplit = preg_split('//u', $word, null, PREG_SPLIT_NO_EMPTY); $strSplit = preg_split('//u', $item, null, PREG_SPLIT_NO_EMPTY); $wordSplit = array_filter($wordSplit, function ($x) use (&$strSplit) { if (in_array(strtolower($x), array_map('strtolower', $strSplit), true)) { $pos = array_search(strtolower($x), array_map('strtolower', $strSplit), true); unset($strSplit[$pos]); return false; } return true; }); if (count($strSplit) === 0) { echo "$word contains all letters of $item" . PHP_EOL; } } echo PHP_EOL; }

Abusive script

This script was stopped while abusing our resources


preferences:
24.49 ms | 411 KiB | 5 Q