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_merge($this->data); //sort($data, SORT_STRING); sort($data); $rs = implode('-', $data); echo $rs."\n"; return $rs; } } // expected result is ['c','b'],['c','b','a'] $a = array( new SortMadness(array('c','b')), new SortMadness(array('c','b','a')), new SortMadness(array('a','b','c')), ); $rs = array_unique($a, SORT_STRING); print_r($rs);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Rp6eK
function name:  (null)
number of ops:  23
compiled vars:  !0 = $a, !1 = $rs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'sortmadness'
   23     1        NEW                                              $2      'SortMadness'
          2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~4      $2
   24     5        NEW                                              $5      'SortMadness'
          6        SEND_VAL_EX                                              <array>
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~4      $5
   25     9        NEW                                              $7      'SortMadness'
         10        SEND_VAL_EX                                              <array>
         11        DO_FCALL                                      0          
         12        ADD_ARRAY_ELEMENT                                ~4      $7
   22    13        ASSIGN                                                   !0, ~4
   28    14        INIT_FCALL                                               'array_unique'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 2
         17        DO_ICALL                                         $10     
         18        ASSIGN                                                   !1, $10
   30    19        INIT_FCALL                                               'print_r'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Class SortMadness:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Rp6eK
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/Rp6eK
function name:  __toString
number of ops:  19
compiled vars:  !0 = $data, !1 = $rs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     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.54 ms | 1400 KiB | 23 Q