3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getWordsWithOnlySpecifedLetters(array $dictionary, $letters) { $strSplit = preg_split('//u', $letters, null, PREG_SPLIT_NO_EMPTY); $strSplitLower = array_map('mb_strtolower', $strSplit); sort($strSplit); $result = []; foreach ($dictionary as $word) { if(mb_strlen($word) <= mb_strlen($letters)) { $wordSplit = preg_split('//u', $word, null, PREG_SPLIT_NO_EMPTY); sort($wordSplit); if (array_map('mb_strtolower', $wordSplit) === $strSplitLower) { $result[] = $word; } } } return $result; } $dictionary = ['apple', 'sample', 'api', 'pia', 'тоҷик']; echo '<pre>' . print_r(getWordsWithOnlySpecifedLetters($dictionary, "aip"), true) . '</pre>';
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated in /in/tBnY6 on line 5 Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated in /in/tBnY6 on line 11 Deprecated: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated in /in/tBnY6 on line 11 <pre>Array ( [0] => api [1] => pia ) </pre>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
54.53 ms | 402 KiB | 8 Q