3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'filesystem-2.4.0-1 comps-extras-11.1-1.1 gnome-mime-data-2.4.2-3.1 glibc-2.5-12 atk-1.12.2-1.fc6 libICE-1.0.1-2.1 db4-4.3.29-9.fc6 elfutils-libelf-0.125-3.el5 ncurses-5.5-24.20060715 libsepol-1.15.2-1.el5 libcap-1.10-26 sqlite-3.3.6-2 pcre-6.6-1.1 gdbm-1.8.0-26.2.1 libsepol-1.15.2-1.el5 libXdmcp-1.0.1-2.1 db4-4.3.29-9.fc6 iptables-1.3.5-1.2.1 libXrender-0.9.1-3.1 libXi-1.0.1-3.1 xorg-x11-font-utils-7.1-2 slang-2.0.6-4.el'; $array = explode(PHP_EOL, $str); array_walk($array, function(&$value, $key) { preg_match('/-\d/', $value, $match, PREG_OFFSET_CAPTURE); $offset = !empty($match) ? $match[0][1] : strlen($value); $value = [ 'name' => substr($value, 0, $offset), 'version' => trim(substr($value, $offset), '-') ]; }); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HVKfE
function name:  (null)
number of ops:  15
compiled vars:  !0 = $str, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'filesystem-2.4.0-1%0Acomps-extras-11.1-1.1%0Agnome-mime-data-2.4.2-3.1%0Aglibc-2.5-12%0Aatk-1.12.2-1.fc6%0AlibICE-1.0.1-2.1%0Adb4-4.3.29-9.fc6%0Aelfutils-libelf-0.125-3.el5%0Ancurses-5.5-24.20060715%0Alibsepol-1.15.2-1.el5%0Alibcap-1.10-26%0Asqlite-3.3.6-2%0Apcre-6.6-1.1%0Agdbm-1.8.0-26.2.1%0Alibsepol-1.15.2-1.el5%0AlibXdmcp-1.0.1-2.1%0Adb4-4.3.29-9.fc6%0Aiptables-1.3.5-1.2.1%0AlibXrender-0.9.1-3.1%0AlibXi-1.0.1-3.1%0Axorg-x11-font-utils-7.1-2%0Aslang-2.0.6-4.el'
   25     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   27     6        INIT_FCALL                                               'array_walk'
          7        SEND_REF                                                 !1
          8        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   36     9        SEND_VAL                                                 ~5
   27    10        DO_ICALL                                                 
   38    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HVKfE
function name:  {closure}
number of ops:  35
compiled vars:  !0 = $value, !1 = $key, !2 = $match, !3 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   28     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAL                                                 '%2F-%5Cd%2F'
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        SEND_VAL                                                 256
          7        DO_ICALL                                                 
   30     8        ISSET_ISEMPTY_CV                                 ~5      !2
          9        BOOL_NOT                                         ~6      ~5
         10      > JMPZ                                                     ~6, ->15
         11    >   FETCH_DIM_R                                      ~7      !2, 0
         12        FETCH_DIM_R                                      ~8      ~7, 1
         13        QM_ASSIGN                                        ~9      ~8
         14      > JMP                                                      ->17
         15    >   STRLEN                                           ~10     !0
         16        QM_ASSIGN                                        ~9      ~10
         17    >   ASSIGN                                                   !3, ~9
   33    18        INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !0
         20        SEND_VAL                                                 0
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                         $12     
         23        INIT_ARRAY                                       ~13     $12, 'name'
   34    24        INIT_FCALL                                               'trim'
         25        INIT_FCALL                                               'substr'
         26        SEND_VAR                                                 !0
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                         $14     
         29        SEND_VAR                                                 $14
         30        SEND_VAL                                                 '-'
         31        DO_ICALL                                         $15     
         32        ADD_ARRAY_ELEMENT                                ~13     $15, 'version'
   32    33        ASSIGN                                                   !0, ~13
   36    34      > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.15 ms | 1021 KiB | 19 Q