3v4l.org

run code in 300+ PHP versions simultaneously
<?php $order = array( 3452342, 5867867, 7867867, 1231233 ); $array = array( array("id" => 7867867, "title" => "Must Be #3"), array("id" => 3452342, "title" => "Must Be #1"), array("id" => 1231233, "title" => "Must Be #4"), array("id" => 5867867, "title" => "Must Be #2"), array("id" => 1111111, "title" => "Dont Care #1"), array("id" => 2222222, "title" => "Dont Care #2"), array("id" => 3333333, "title" => "Dont Care #3"), array("id" => 4444444, "title" => "Dont Care #4") ); function custom_compare($a, $b){ global $order; $a = array_search($a["id"], $order); $b = array_search($b["id"], $order); if($a === false && $b === false) { // both items are dont cares return 0; // a == b } else if ($a === false) { // $a is a dont care item return 1; // $a > $b } else if ($b === false) { // $b is a dont care item return -1; // $a < $b } else { return $a - $b; } } shuffle($array); // for testing var_dump($array); // before usort($array, "custom_compare"); var_dump($array); // after $tz_ini = ini_get('date.timezone'); if (empty($tz_ini)){ date_default_timezone_set('Australia/Melbourne'); //date_default_timezone_set("Europe/Vienna"); } else{ //echo 'Script timezone differs from ini-set timezone.'; //do nothing, timezone already set; } echo strtotime("10 September 2014"), "\n"; echo time(), "\n"; if ( date('I', strtotime("6 October 2014")) == 1){ echo 'it is DST'; $timeint -= 11*3600; } else{ echo 'it is NOT DST'; $timeint -= 10*3600; } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 46
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/NNPJu
function name:  (null)
number of ops:  49
compiled vars:  !0 = $order, !1 = $array, !2 = $tz_ini, !3 = $timeint
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   37     2        INIT_FCALL                                               'shuffle'
          3        SEND_REF                                                 !1
          4        DO_ICALL                                                 
   38     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
   39     8        INIT_FCALL                                               'usort'
          9        SEND_REF                                                 !1
         10        SEND_VAL                                                 'custom_compare'
         11        DO_ICALL                                                 
   40    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
   43    15        INIT_FCALL                                               'ini_get'
         16        SEND_VAL                                                 'date.timezone'
         17        DO_ICALL                                         $10     
         18        ASSIGN                                                   !2, $10
   44    19        ISSET_ISEMPTY_CV                                         !2
         20      > JMPZ                                                     ~12, ->25
   45    21    >   INIT_FCALL                                               'date_default_timezone_set'
         22        SEND_VAL                                                 'Australia%2FMelbourne'
         23        DO_ICALL                                                 
         24      > JMP                                                      ->25
   52    25    >   INIT_FCALL                                               'strtotime'
         26        SEND_VAL                                                 '10+September+2014'
         27        DO_ICALL                                         $14     
         28        ECHO                                                     $14
         29        ECHO                                                     '%0A'
   53    30        INIT_FCALL                                               'time'
         31        DO_ICALL                                         $15     
         32        ECHO                                                     $15
         33        ECHO                                                     '%0A'
   55    34        INIT_FCALL                                               'date'
         35        SEND_VAL                                                 'I'
         36        INIT_FCALL                                               'strtotime'
         37        SEND_VAL                                                 '6+October+2014'
         38        DO_ICALL                                         $16     
         39        SEND_VAR                                                 $16
         40        DO_ICALL                                         $17     
         41        IS_EQUAL                                                 $17, 1
         42      > JMPZ                                                     ~18, ->46
   56    43    >   ECHO                                                     'it+is+DST'
   57    44        ASSIGN_OP                                     2          !3, 39600
         45      > JMP                                                      ->48
   60    46    >   ECHO                                                     'it+is+NOT+DST'
   61    47        ASSIGN_OP                                     2          !3, 36000
   63    48    > > RETURN                                                   1

Function custom_compare:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/NNPJu
function name:  custom_compare
number of ops:  33
compiled vars:  !0 = $a, !1 = $b, !2 = $order
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        BIND_GLOBAL                                              !2, 'order'
   21     3        INIT_FCALL                                               'array_search'
          4        FETCH_DIM_R                                      ~3      !0, 'id'
          5        SEND_VAL                                                 ~3
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !0, $4
   22     9        INIT_FCALL                                               'array_search'
         10        FETCH_DIM_R                                      ~6      !1, 'id'
         11        SEND_VAL                                                 ~6
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $7      
         14        ASSIGN                                                   !1, $7
   23    15        TYPE_CHECK                                    4  ~9      !0
         16      > JMPZ_EX                                          ~9      ~9, ->19
         17    >   TYPE_CHECK                                    4  ~10     !1
         18        BOOL                                             ~9      ~10
         19    > > JMPZ                                                     ~9, ->22
   24    20    > > RETURN                                                   0
         21*       JMP                                                      ->32
   26    22    >   TYPE_CHECK                                    4          !0
         23      > JMPZ                                                     ~11, ->26
   27    24    > > RETURN                                                   1
         25*       JMP                                                      ->32
   29    26    >   TYPE_CHECK                                    4          !1
         27      > JMPZ                                                     ~12, ->30
   30    28    > > RETURN                                                   -1
         29*       JMP                                                      ->32
   33    30    >   SUB                                              ~13     !0, !1
         31      > RETURN                                                   ~13
   35    32*     > RETURN                                                   null

End of function custom_compare

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.67 ms | 1404 KiB | 31 Q