3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrDates = array( "12/25/2009","01/10/2008","02/12/2000","03/17/1948", "03/06/1948","11/25/1972","10/23/2009","01/14/2008", "02/22/2000","03/27/1948","03/16/1948","11/24/1972", "11/13/2009","11/10/2008","12/12/2000","05/17/1948", "05/06/1948","10/25/1972","09/23/2009","02/14/2008", "03/22/2000","04/27/1948","04/16/1948","08/24/1972" ); /** * swapValue2() * @param array $array * @param int $dex * @param int $dex2 * swap two array values **/ function swapValues2( $array, $dex, $dex2 ) { list($array[$dex],$array[$dex2]) = array($array[$dex2], $array[$dex]); return $array; } /** * bubbleSort() * @param array $array * performs bubble sort using optimized implementation **/ function bubbleSort( $array) { for( $out=0, $size = count($array); $out < $size - 1 ; $out++ ) { for( $in = $out + 1; $in < $size; $in++ ) { if (strtotime($array[ $out ]) > strtotime($array[ $in ])) { $array = swapValues2($array, $out, $in); } } } return $array; } var_dump(bubbleSort($arrDates));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ctoXZ
function name:  (null)
number of ops:  8
compiled vars:  !0 = $arrDates
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   48     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'bubblesort'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function swapvalues2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ctoXZ
function name:  swapValues2
number of ops:  16
compiled vars:  !0 = $array, !1 = $dex, !2 = $dex2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   19     3        FETCH_DIM_R                                      ~3      !0, !2
          4        INIT_ARRAY                                       ~4      ~3
          5        FETCH_DIM_R                                      ~5      !0, !1
          6        ADD_ARRAY_ELEMENT                                ~4      ~5
          7        FETCH_LIST_R                                     $6      ~4, 0
          8        ASSIGN_DIM                                               !0, !1
          9        OP_DATA                                                  $6
         10        FETCH_LIST_R                                     $8      ~4, 1
         11        ASSIGN_DIM                                               !0, !2
         12        OP_DATA                                                  $8
         13        FREE                                                     ~4
   20    14      > RETURN                                                   !0
   21    15*     > RETURN                                                   null

End of function swapvalues2

Function bubblesort:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 5
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 8
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 5
Branch analysis from position: 31
Branch analysis from position: 5
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 8
Branch analysis from position: 27
Branch analysis from position: 8
Branch analysis from position: 24
filename:       /in/ctoXZ
function name:  bubbleSort
number of ops:  33
compiled vars:  !0 = $array, !1 = $out, !2 = $size, !3 = $in
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        ASSIGN                                                   !1, 0
          2        COUNT                                            ~5      !0
          3        ASSIGN                                                   !2, ~5
          4      > JMP                                                      ->28
   35     5    >   ADD                                              ~7      !1, 1
          6        ASSIGN                                                   !3, ~7
          7      > JMP                                                      ->25
   39     8    >   INIT_FCALL                                               'strtotime'
          9        FETCH_DIM_R                                      ~9      !0, !1
         10        SEND_VAL                                                 ~9
         11        DO_ICALL                                         $10     
   40    12        INIT_FCALL                                               'strtotime'
         13        FETCH_DIM_R                                      ~11     !0, !3
         14        SEND_VAL                                                 ~11
         15        DO_ICALL                                         $12     
         16        IS_SMALLER                                               $12, $10
         17      > JMPZ                                                     ~13, ->24
   42    18    >   INIT_FCALL                                               'swapvalues2'
         19        SEND_VAR                                                 !0
         20        SEND_VAR                                                 !1
         21        SEND_VAR                                                 !3
         22        DO_FCALL                                      0  $14     
         23        ASSIGN                                                   !0, $14
   37    24    >   PRE_INC                                                  !3
   36    25    >   IS_SMALLER                                               !3, !2
         26      > JMPNZ                                                    ~17, ->8
   33    27    >   PRE_INC                                                  !1
   32    28    >   SUB                                              ~19     !2, 1
         29        IS_SMALLER                                               !1, ~19
         30      > JMPNZ                                                    ~20, ->5
   46    31    > > RETURN                                                   !0
   47    32*     > RETURN                                                   null

End of function bubblesort

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.52 ms | 1403 KiB | 19 Q