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>';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tBnY6
function name:  (null)
number of ops:  13
compiled vars:  !0 = $dictionary
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, <array>
   21     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'getwordswithonlyspecifedletters'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'aip'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $3      
          9        CONCAT                                           ~4      '%3Cpre%3E', $3
         10        CONCAT                                           ~5      ~4, '%3C%2Fpre%3E'
         11        ECHO                                                     ~5
         12      > RETURN                                                   1

Function getwordswithonlyspecifedletters:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 47
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 47
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 46
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 46
Branch analysis from position: 46
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/tBnY6
function name:  getWordsWithOnlySpecifedLetters
number of ops:  50
compiled vars:  !0 = $dictionary, !1 = $letters, !2 = $strSplit, !3 = $strSplitLower, !4 = $result, !5 = $word, !6 = $wordSplit
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'preg_split'
          3        SEND_VAL                                                 '%2F%2Fu'
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 null
          6        SEND_VAL                                                 1
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !2, $7
    6     9        INIT_FCALL                                               'array_map'
         10        SEND_VAL                                                 'mb_strtolower'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !3, $9
    7    14        INIT_FCALL                                               'sort'
         15        SEND_REF                                                 !2
         16        DO_ICALL                                                 
    8    17        ASSIGN                                                   !4, <array>
    9    18      > FE_RESET_R                                       $13     !0, ->47
         19    > > FE_FETCH_R                                               $13, !5, ->47
   10    20    >   INIT_FCALL                                               'mb_strlen'
         21        SEND_VAR                                                 !5
         22        DO_ICALL                                         $14     
         23        INIT_FCALL                                               'mb_strlen'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $15     
         26        IS_SMALLER_OR_EQUAL                                      $14, $15
         27      > JMPZ                                                     ~16, ->46
   11    28    >   INIT_FCALL                                               'preg_split'
         29        SEND_VAL                                                 '%2F%2Fu'
         30        SEND_VAR                                                 !5
         31        SEND_VAL                                                 null
         32        SEND_VAL                                                 1
         33        DO_ICALL                                         $17     
         34        ASSIGN                                                   !6, $17
   12    35        INIT_FCALL                                               'sort'
         36        SEND_REF                                                 !6
         37        DO_ICALL                                                 
   13    38        INIT_FCALL                                               'array_map'
         39        SEND_VAL                                                 'mb_strtolower'
         40        SEND_VAR                                                 !6
         41        DO_ICALL                                         $20     
         42        IS_IDENTICAL                                             !3, $20
         43      > JMPZ                                                     ~21, ->46
   14    44    >   ASSIGN_DIM                                               !4
         45        OP_DATA                                                  !5
    9    46    > > JMP                                                      ->19
         47    >   FE_FREE                                                  $13
   18    48      > RETURN                                                   !4
   19    49*     > RETURN                                                   null

End of function getwordswithonlyspecifedletters

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.39 ms | 1402 KiB | 24 Q