3v4l.org

run code in 300+ PHP versions simultaneously
<?php $object1 = new stdClass(); $object1->id = 1; $object1->nome = 'B'; $object2 = new stdClass(); $object2->id = 1; $object2->nome = 'A'; $object3 = new stdClass(); $object3->id = 1; $object3->nome = 'L'; $dados = array($object3, $object1, $object2); function orderData(array $data, $orderByField = 'nome') { $asc = array(); foreach ($data as $key1 => $object1) { $field1 = $object1->{$orderByField}; foreach ($data as $key2 => $object2) { $field2 = $object2->{$orderByField}; if ($field1 != $field2) { $asc[$key1] = $object2; } } } return $asc; } var_dump( orderData($dados) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RBFci
function name:  (null)
number of ops:  32
compiled vars:  !0 = $object1, !1 = $object2, !2 = $object3, !3 = $dados
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $4      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
    4     3        ASSIGN_OBJ                                               !0, 'id'
          4        OP_DATA                                                  1
    5     5        ASSIGN_OBJ                                               !0, 'nome'
          6        OP_DATA                                                  'B'
    7     7        NEW                                              $9      'stdClass'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $9
    8    10        ASSIGN_OBJ                                               !1, 'id'
         11        OP_DATA                                                  1
    9    12        ASSIGN_OBJ                                               !1, 'nome'
         13        OP_DATA                                                  'A'
   11    14        NEW                                              $14     'stdClass'
         15        DO_FCALL                                      0          
         16        ASSIGN                                                   !2, $14
   12    17        ASSIGN_OBJ                                               !2, 'id'
         18        OP_DATA                                                  1
   13    19        ASSIGN_OBJ                                               !2, 'nome'
         20        OP_DATA                                                  'L'
   15    21        INIT_ARRAY                                       ~19     !2
         22        ADD_ARRAY_ELEMENT                                ~19     !0
         23        ADD_ARRAY_ELEMENT                                ~19     !1
         24        ASSIGN                                                   !3, ~19
   35    25        INIT_FCALL                                               'var_dump'
         26        INIT_FCALL                                               'orderdata'
         27        SEND_VAR                                                 !3
         28        DO_FCALL                                      0  $21     
         29        SEND_VAR                                                 $21
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Function orderdata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 18
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 18
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/RBFci
function name:  orderData
number of ops:  23
compiled vars:  !0 = $data, !1 = $orderByField, !2 = $asc, !3 = $object1, !4 = $key1, !5 = $field1, !6 = $object2, !7 = $key2, !8 = $field2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'nome'
   18     2        ASSIGN                                                   !2, <array>
   20     3      > FE_RESET_R                                       $10     !0, ->20
          4    > > FE_FETCH_R                                       ~11     $10, !3, ->20
          5    >   ASSIGN                                                   !4, ~11
   21     6        FETCH_OBJ_R                                      ~13     !3, !1
          7        ASSIGN                                                   !5, ~13
   23     8      > FE_RESET_R                                       $15     !0, ->18
          9    > > FE_FETCH_R                                       ~16     $15, !6, ->18
         10    >   ASSIGN                                                   !7, ~16
   24    11        FETCH_OBJ_R                                      ~18     !6, !1
         12        ASSIGN                                                   !8, ~18
   26    13        IS_NOT_EQUAL                                             !5, !8
         14      > JMPZ                                                     ~20, ->17
   27    15    >   ASSIGN_DIM                                               !2, !4
         16        OP_DATA                                                  !6
   23    17    > > JMP                                                      ->9
         18    >   FE_FREE                                                  $15
   20    19      > JMP                                                      ->4
         20    >   FE_FREE                                                  $10
   32    21      > RETURN                                                   !2
   33    22*     > RETURN                                                   null

End of function orderdata

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.14 ms | 1403 KiB | 16 Q