3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ '', 3445, '', 3446, '', 3452, '', 3530, 3555, ]; $str = serialize($arr); echo $str; // a:9:{i:0;s:0:"";i:1;i:3445;i:2;s:0:"";i:3;i:3446;i:4;s:0:"";i:5;i:3452;i:6;s:0:"";i:7;i:3530;i:8;i:3555;} echo PHP_EOL; $arr = unserialize($str); print_r($arr); // Array ( [0] => [1] => 3445 [2] => [3] => 3446 [4] => [5] => 3452 [6] => [7] => 3530 [8] => 3555 ) echo PHP_EOL; $arrayLen = count($arr); echo 'array length : ' . $arrayLen; // 9 echo PHP_EOL; // return index of value $needle = 3452; $index = array_search($needle, $arr); echo 'found value ' . $needle . ' at index : ' . $index; // found value 3452 at index 5 echo PHP_EOL; // Count only non empty array entries $arrNonEmpty = array_filter($arr, function($element) { return !empty($element); }); $count = count($arrNonEmpty); echo 'non empty values in array : ' . $count; echo PHP_EOL; print_r($arrNonEmpty); // rebase array indices $arrNonEmpty = array_values($arrNonEmpty); echo 'rebased indices:' . PHP_EOL; print_r($arrNonEmpty);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2fM18
function name:  (null)
number of ops:  54
compiled vars:  !0 = $arr, !1 = $str, !2 = $arrayLen, !3 = $needle, !4 = $index, !5 = $arrNonEmpty, !6 = $count
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    7     1        INIT_FCALL                                                   'serialize'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $8      
          4        ASSIGN                                                       !1, $8
    8     5        ECHO                                                         !1
    9     6        ECHO                                                         '%0A'
   11     7        INIT_FCALL                                                   'unserialize'
          8        SEND_VAR                                                     !1
          9        DO_ICALL                                             $10     
         10        ASSIGN                                                       !0, $10
   12    11        INIT_FCALL                                                   'print_r'
         12        SEND_VAR                                                     !0
         13        DO_ICALL                                                     
   13    14        ECHO                                                         '%0A'
   15    15        COUNT                                                ~13     !0
         16        ASSIGN                                                       !2, ~13
   16    17        CONCAT                                               ~15     'array+length+%3A+', !2
         18        ECHO                                                         ~15
   17    19        ECHO                                                         '%0A'
   20    20        ASSIGN                                                       !3, 3452
   21    21        INIT_FCALL                                                   'array_search'
         22        SEND_VAR                                                     !3
         23        SEND_VAR                                                     !0
         24        DO_ICALL                                             $17     
         25        ASSIGN                                                       !4, $17
   22    26        CONCAT                                               ~19     'found+value+', !3
         27        CONCAT                                               ~20     ~19, '+at+index+%3A+'
         28        CONCAT                                               ~21     ~20, !4
         29        ECHO                                                         ~21
   23    30        ECHO                                                         '%0A'
   26    31        INIT_FCALL                                                   'array_filter'
         32        SEND_VAR                                                     !0
         33        DECLARE_LAMBDA_FUNCTION                              ~22     [0]
         34        SEND_VAL                                                     ~22
         35        DO_ICALL                                             $23     
         36        ASSIGN                                                       !5, $23
   27    37        COUNT                                                ~25     !5
         38        ASSIGN                                                       !6, ~25
   28    39        CONCAT                                               ~27     'non+empty+values+in+array+%3A+', !6
         40        ECHO                                                         ~27
   29    41        ECHO                                                         '%0A'
   31    42        INIT_FCALL                                                   'print_r'
         43        SEND_VAR                                                     !5
         44        DO_ICALL                                                     
   34    45        INIT_FCALL                                                   'array_values'
         46        SEND_VAR                                                     !5
         47        DO_ICALL                                             $29     
         48        ASSIGN                                                       !5, $29
   35    49        ECHO                                                         'rebased+indices%3A%0A'
   37    50        INIT_FCALL                                                   'print_r'
         51        SEND_VAR                                                     !5
         52        DO_ICALL                                                     
         53      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2fM18
function name:  {closure:/in/2fM18:26}
number of ops:  5
compiled vars:  !0 = $element
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   RECV                                                 !0      
          1        ISSET_ISEMPTY_CV                                     ~1      !0
          2        BOOL_NOT                                             ~2      ~1
          3      > RETURN                                                       ~2
          4*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.74 ms | 2287 KiB | 19 Q