3v4l.org

run code in 300+ PHP versions simultaneously
<?php function splitDatabaseArray($array) { ksort($array); $return = array(); $last_database_table = array(); foreach ($array as $index => $value) { $database_table = array(); list($database_table[0], $database_table[1]) = explode('.', $index); if ($last_database_table != $database_table) $row = &$return[]; $last_database_table = $database_table; $row[$index] = $value; } return $return; } $array = array ( 'database1.table1.fieldname' => "test", 'database1.table1.fieldname1' => "test1", 'database2.table2.fieldname' => "test2"); var_dump(splitDatabaseArray($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e7nWu
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, <array>
   25     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'splitdatabasearray'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function splitdatabasearray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 29
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 25
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/e7nWu
function name:  splitDatabaseArray
number of ops:  32
compiled vars:  !0 = $array, !1 = $return, !2 = $last_database_table, !3 = $value, !4 = $index, !5 = $database_table, !6 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'ksort'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
    5     4        ASSIGN                                                   !1, <array>
    6     5        ASSIGN                                                   !2, <array>
    7     6      > FE_RESET_R                                       $10     !0, ->29
          7    > > FE_FETCH_R                                       ~11     $10, !3, ->29
          8    >   ASSIGN                                                   !4, ~11
    9     9        ASSIGN                                                   !5, <array>
   10    10        INIT_FCALL                                               'explode'
         11        SEND_VAL                                                 '.'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $14     
         14        FETCH_LIST_R                                     $15     $14, 0
         15        ASSIGN_DIM                                               !5, 0
         16        OP_DATA                                                  $15
         17        FETCH_LIST_R                                     $17     $14, 1
         18        ASSIGN_DIM                                               !5, 1
         19        OP_DATA                                                  $17
         20        FREE                                                     $14
   11    21        IS_NOT_EQUAL                                             !2, !5
         22      > JMPZ                                                     ~19, ->25
   12    23    >   FETCH_DIM_W                                      $20     !1
         24        ASSIGN_REF                                               !6, $20
   13    25    >   ASSIGN                                                   !2, !5
   14    26        ASSIGN_DIM                                               !6, !4
         27        OP_DATA                                                  !3
    7    28      > JMP                                                      ->7
         29    >   FE_FREE                                                  $10
   16    30      > RETURN                                                   !1
   17    31*     > RETURN                                                   null

End of function splitdatabasearray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.5 ms | 1403 KiB | 20 Q