3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SortMadness { private $data; public function __construct($data) { $this->data = $data; } public function __toString() { //$data = array_map(function($item) { return $item; }, $this->data); $data = array_merge($this->data); sort($data); $rs = implode('-', $data); echo $rs."\n"; return $rs; } } // expected order is ['a','b'],['c','b','a'],['c','b'] $a = array( new SortMadness(array('c','b')), new SortMadness(array('c','b','a')), new SortMadness(array('a','b')), ); sort($a, SORT_STRING); print_r($a); usort($a, 'strcmp'); print_r($a);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1VBfj
function name:  (null)
number of ops:  29
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'sortmadness'
   23     1        NEW                                              $1      'SortMadness'
          2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~3      $1
   24     5        NEW                                              $4      'SortMadness'
          6        SEND_VAL_EX                                              <array>
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~3      $4
   25     9        NEW                                              $6      'SortMadness'
         10        SEND_VAL_EX                                              <array>
         11        DO_FCALL                                      0          
         12        ADD_ARRAY_ELEMENT                                ~3      $6
   22    13        ASSIGN                                                   !0, ~3
   28    14        INIT_FCALL                                               'sort'
         15        SEND_REF                                                 !0
         16        SEND_VAL                                                 2
         17        DO_ICALL                                                 
   30    18        INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
   32    21        INIT_FCALL                                               'usort'
         22        SEND_REF                                                 !0
         23        SEND_VAL                                                 'strcmp'
         24        DO_ICALL                                                 
   34    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Class SortMadness:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1VBfj
function name:  __construct
number of ops:  4
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               'data'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function __construct

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1VBfj
function name:  __toString
number of ops:  19
compiled vars:  !0 = $data, !1 = $rs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'array_merge'
          1        FETCH_OBJ_R                                      ~2      'data'
          2        SEND_VAL                                                 ~2
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
   13     5        INIT_FCALL                                               'sort'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
   14     8        INIT_FCALL                                               'implode'
          9        SEND_VAL                                                 '-'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $6      
         12        ASSIGN                                                   !1, $6
   15    13        CONCAT                                           ~8      !1, '%0A'
         14        ECHO                                                     ~8
   17    15        VERIFY_RETURN_TYPE                                       !1
         16      > RETURN                                                   !1
   18    17*       VERIFY_RETURN_TYPE                                       
         18*     > RETURN                                                   null

End of function __tostring

End of class SortMadness.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.45 ms | 1400 KiB | 23 Q