3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mysort($a,$b){ return strlen($b)-strlen($a); } $data = array("kaushik","kaushik is","kaushik is great","is","is great","great"); //$data = array("usb","pc","cam 168","cam","168"); usort($data,'mysort'); // print_r($data); $current = ""; for($i=0;$i<count($data);$i++) { $current=$data[$i]; for($j=0;$j<count($data);$j++) { if($i<>$j) { if((str_replace($data[$j],"",$current))!=$current) { $data[$j]=""; }; } } } for($i=0;$i<count($data);$i++) { if($data[$i]!="") { echo $data[$i]."\n"; } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 8
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 34
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 40
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 34
Branch analysis from position: 44
Branch analysis from position: 34
Branch analysis from position: 40
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 12
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 8
Branch analysis from position: 32
Branch analysis from position: 8
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 12
Branch analysis from position: 28
Branch analysis from position: 12
Branch analysis from position: 24
Branch analysis from position: 24
filename:       /in/M6ImD
function name:  (null)
number of ops:  45
compiled vars:  !0 = $data, !1 = $current, !2 = $i, !3 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'mysort'
          4        DO_ICALL                                                 
   14     5        ASSIGN                                                   !1, ''
   16     6        ASSIGN                                                   !2, 0
          7      > JMP                                                      ->29
   18     8    >   FETCH_DIM_R                                      ~8      !0, !2
          9        ASSIGN                                                   !1, ~8
   20    10        ASSIGN                                                   !3, 0
         11      > JMP                                                      ->25
   22    12    >   IS_NOT_EQUAL                                             !2, !3
         13      > JMPZ                                                     ~11, ->24
   24    14    >   INIT_FCALL                                               'str_replace'
         15        FETCH_DIM_R                                      ~12     !0, !3
         16        SEND_VAL                                                 ~12
         17        SEND_VAL                                                 ''
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $13     
         20        IS_NOT_EQUAL                                             !1, $13
         21      > JMPZ                                                     ~14, ->24
   26    22    >   ASSIGN_DIM                                               !0, !3
         23        OP_DATA                                                  ''
   20    24    >   PRE_INC                                                  !3
         25    >   COUNT                                            ~17     !0
         26        IS_SMALLER                                               !3, ~17
         27      > JMPNZ                                                    ~18, ->12
   16    28    >   PRE_INC                                                  !2
         29    >   COUNT                                            ~20     !0
         30        IS_SMALLER                                               !2, ~20
         31      > JMPNZ                                                    ~21, ->8
   35    32    >   ASSIGN                                                   !2, 0
         33      > JMP                                                      ->41
   37    34    >   FETCH_DIM_R                                      ~23     !0, !2
         35        IS_NOT_EQUAL                                             ~23, ''
         36      > JMPZ                                                     ~24, ->40
   39    37    >   FETCH_DIM_R                                      ~25     !0, !2
         38        CONCAT                                           ~26     ~25, '%0A'
         39        ECHO                                                     ~26
   35    40    >   PRE_INC                                                  !2
         41    >   COUNT                                            ~28     !0
         42        IS_SMALLER                                               !2, ~28
         43      > JMPNZ                                                    ~29, ->34
   44    44    > > RETURN                                                   1

Function mysort:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M6ImD
function name:  mysort
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        STRLEN                                           ~2      !1
          3        STRLEN                                           ~3      !0
          4        SUB                                              ~4      ~2, ~3
          5      > RETURN                                                   ~4
    4     6*     > RETURN                                                   null

End of function mysort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.63 ms | 1392 KiB | 17 Q