3v4l.org

run code in 300+ PHP versions simultaneously
<?php $multidimArray = [ 'a' => [ 'boolean' => true, 'natString' => 'text10', 'object' => (object)['prop' => 2], 'float' => -.5, 'mixed' => [] ], 'b' => [ 'boolean' => true, 'natString' => 'text12', 'object' => (object)['prop' => 4], 'float' => 0, 'mixed' => null ], 'c' => [ 'boolean' => false, 'natString' => 'text100', 'object' => (object)['prop' => 9], 'float' => -.5, 'mixed' => false ], 'd' => [ 'boolean' => true, 'natString' => 'text1', 'object' => (object)['prop' => 9], 'float' => -5, 'mixed' => "\0" ], 'e' => [ 'boolean' => false, 'natString' => 'text2', 'object' => (object)['prop' => 2], 'float' => .5, 'mixed' => '' ] ]; //Sorting logic: boolean DESC (false = 0, true = 1, so trues before falses), float ASC uasort($multidimArray, fn($a, $b) => [$b['boolean'], $a['float']] <=> [$a['boolean'], $b['float']]); var_export($multidimArray); echo "\n---\n"; //Sorting logic: mixed ASC, object ASC, boolean ASC uasort($multidimArray, fn($a, $b) => [$a['mixed'], $a['object']->prop, $a['boolean']] <=> [$b['mixed'], $b['object']->prop, $b['boolean']]); var_export($multidimArray); echo "\n---\n"; //Sorting logic: property count of object ASC, iterability of mixed DESC, natString length ASC, natString ASC uasort($multidimArray, fn($a, $b) => [count(get_object_vars($a['object'])), is_iterable($a['mixed']), strlen($a['natString']), $a['natString']] <=> [count(get_object_vars($b['object'])), is_iterable($b['mixed']), strlen($b['natString']), $b['natString']] ); var_export($multidimArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N5hs1
function name:  (null)
number of ops:  63
compiled vars:  !0 = $multidimArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_ARRAY                                       ~1      <true>, 'boolean'
    5     1        ADD_ARRAY_ELEMENT                                ~1      'text10', 'natString'
    6     2        CAST                                          8  ~2      <array>
          3        ADD_ARRAY_ELEMENT                                ~1      ~2, 'object'
    4     4        ADD_ARRAY_ELEMENT                                ~1      -0.5, 'float'
          5        ADD_ARRAY_ELEMENT                                ~1      <array>, 'mixed'
          6        INIT_ARRAY                                       ~3      ~1, 'a'
          7        INIT_ARRAY                                       ~4      <true>, 'boolean'
   12     8        ADD_ARRAY_ELEMENT                                ~4      'text12', 'natString'
   13     9        CAST                                          8  ~5      <array>
         10        ADD_ARRAY_ELEMENT                                ~4      ~5, 'object'
   14    11        ADD_ARRAY_ELEMENT                                ~4      0, 'float'
    4    12        ADD_ARRAY_ELEMENT                                ~4      null, 'mixed'
         13        ADD_ARRAY_ELEMENT                                ~3      ~4, 'b'
         14        INIT_ARRAY                                       ~6      <false>, 'boolean'
   19    15        ADD_ARRAY_ELEMENT                                ~6      'text100', 'natString'
   20    16        CAST                                          8  ~7      <array>
         17        ADD_ARRAY_ELEMENT                                ~6      ~7, 'object'
    4    18        ADD_ARRAY_ELEMENT                                ~6      -0.5, 'float'
         19        ADD_ARRAY_ELEMENT                                ~6      <false>, 'mixed'
         20        ADD_ARRAY_ELEMENT                                ~3      ~6, 'c'
         21        INIT_ARRAY                                       ~8      <true>, 'boolean'
   26    22        ADD_ARRAY_ELEMENT                                ~8      'text1', 'natString'
   27    23        CAST                                          8  ~9      <array>
         24        ADD_ARRAY_ELEMENT                                ~8      ~9, 'object'
    4    25        ADD_ARRAY_ELEMENT                                ~8      -5, 'float'
   29    26        ADD_ARRAY_ELEMENT                                ~8      '%00', 'mixed'
         27        ADD_ARRAY_ELEMENT                                ~3      ~8, 'd'
    4    28        INIT_ARRAY                                       ~10     <false>, 'boolean'
   33    29        ADD_ARRAY_ELEMENT                                ~10     'text2', 'natString'
   34    30        CAST                                          8  ~11     <array>
         31        ADD_ARRAY_ELEMENT                                ~10     ~11, 'object'
   35    32        ADD_ARRAY_ELEMENT                                ~10     0.5, 'float'
   36    33        ADD_ARRAY_ELEMENT                                ~10     '', 'mixed'
         34        ADD_ARRAY_ELEMENT                                ~3      ~10, 'e'
    2    35        ASSIGN                                                   !0, ~3
   41    36        INIT_FCALL                                               'uasort'
         37        SEND_REF                                                 !0
         38        DECLARE_LAMBDA_FUNCTION                          ~13     [0]
         39        SEND_VAL                                                 ~13
         40        DO_ICALL                                                 
   42    41        INIT_FCALL                                               'var_export'
         42        SEND_VAR                                                 !0
         43        DO_ICALL                                                 
   43    44        ECHO                                                     '%0A---%0A'
   46    45        INIT_FCALL                                               'uasort'
         46        SEND_REF                                                 !0
         47        DECLARE_LAMBDA_FUNCTION                          ~16     [1]
         48        SEND_VAL                                                 ~16
         49        DO_ICALL                                                 
   47    50        INIT_FCALL                                               'var_export'
         51        SEND_VAR                                                 !0
         52        DO_ICALL                                                 
   48    53        ECHO                                                     '%0A---%0A'
   51    54        INIT_FCALL                                               'uasort'
         55        SEND_REF                                                 !0
         56        DECLARE_LAMBDA_FUNCTION                          ~19     [2]
   55    57        SEND_VAL                                                 ~19
   51    58        DO_ICALL                                                 
   56    59        INIT_FCALL                                               'var_export'
         60        SEND_VAR                                                 !0
         61        DO_ICALL                                                 
         62      > 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/N5hs1
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !1, 'boolean'
          3        INIT_ARRAY                                       ~3      ~2
          4        FETCH_DIM_R                                      ~4      !0, 'float'
          5        ADD_ARRAY_ELEMENT                                ~3      ~4
          6        FETCH_DIM_R                                      ~5      !0, 'boolean'
          7        INIT_ARRAY                                       ~6      ~5
          8        FETCH_DIM_R                                      ~7      !1, 'float'
          9        ADD_ARRAY_ELEMENT                                ~6      ~7
         10        SPACESHIP                                        ~8      ~3, ~6
         11      > RETURN                                                   ~8
         12*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N5hs1
function name:  {closure}
number of ops:  19
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !0, 'mixed'
          3        INIT_ARRAY                                       ~3      ~2
          4        FETCH_DIM_R                                      ~4      !0, 'object'
          5        FETCH_OBJ_R                                      ~5      ~4, 'prop'
          6        ADD_ARRAY_ELEMENT                                ~3      ~5
          7        FETCH_DIM_R                                      ~6      !0, 'boolean'
          8        ADD_ARRAY_ELEMENT                                ~3      ~6
          9        FETCH_DIM_R                                      ~7      !1, 'mixed'
         10        INIT_ARRAY                                       ~8      ~7
         11        FETCH_DIM_R                                      ~9      !1, 'object'
         12        FETCH_OBJ_R                                      ~10     ~9, 'prop'
         13        ADD_ARRAY_ELEMENT                                ~8      ~10
         14        FETCH_DIM_R                                      ~11     !1, 'boolean'
         15        ADD_ARRAY_ELEMENT                                ~8      ~11
         16        SPACESHIP                                        ~12     ~3, ~8
         17      > RETURN                                                   ~12
         18*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N5hs1
function name:  {closure}
number of ops:  37
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   52     2        INIT_FCALL                                               'get_object_vars'
          3        FETCH_DIM_R                                      ~2      !0, 'object'
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6        COUNT                                            ~4      $3
          7        INIT_ARRAY                                       ~5      ~4
          8        INIT_FCALL                                               'is_iterable'
          9        FETCH_DIM_R                                      ~6      !0, 'mixed'
         10        SEND_VAL                                                 ~6
         11        DO_ICALL                                         $7      
         12        ADD_ARRAY_ELEMENT                                ~5      $7
         13        FETCH_DIM_R                                      ~8      !0, 'natString'
         14        STRLEN                                           ~9      ~8
         15        ADD_ARRAY_ELEMENT                                ~5      ~9
         16        FETCH_DIM_R                                      ~10     !0, 'natString'
         17        ADD_ARRAY_ELEMENT                                ~5      ~10
   54    18        INIT_FCALL                                               'get_object_vars'
         19        FETCH_DIM_R                                      ~11     !1, 'object'
         20        SEND_VAL                                                 ~11
         21        DO_ICALL                                         $12     
         22        COUNT                                            ~13     $12
         23        INIT_ARRAY                                       ~14     ~13
         24        INIT_FCALL                                               'is_iterable'
         25        FETCH_DIM_R                                      ~15     !1, 'mixed'
         26        SEND_VAL                                                 ~15
         27        DO_ICALL                                         $16     
         28        ADD_ARRAY_ELEMENT                                ~14     $16
         29        FETCH_DIM_R                                      ~17     !1, 'natString'
         30        STRLEN                                           ~18     ~17
         31        ADD_ARRAY_ELEMENT                                ~14     ~18
         32        FETCH_DIM_R                                      ~19     !1, 'natString'
         33        ADD_ARRAY_ELEMENT                                ~14     ~19
         34        SPACESHIP                                        ~20     ~5, ~14
         35      > RETURN                                                   ~20
   55    36*     > RETURN                                                   null

End of Dynamic Function 2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.44 ms | 1475 KiB | 17 Q