3v4l.org

run code in 300+ PHP versions simultaneously
<?php $colors = array( array(0,0,0), array(255,0,0), array(0,255,0), array(0,0,255), array(255,255,0), array(0,255,255), array(255,0,255), array(192,192,192), array(255,255,255) ); function colorToLum($r, $g, $b) { return (0.299 * $r + 0.587 * $g + 0.114 * $g); } usort( $colors, function ($one, $two) { $lumOne = colorToLum($one[0], $one[1], $one[2]); $lumTwo = colorToLum($two[0], $two[1], $two[2]); return $lumTwo - $lumOne; } ); var_dump($colors);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d8m0m
function name:  (null)
number of ops:  10
compiled vars:  !0 = $colors
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   19     1        INIT_FCALL                                               'usort'
   20     2        SEND_REF                                                 !0
   21     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fd8m0m%3A21%240'
   25     4        SEND_VAL                                                 ~2
          5        DO_ICALL                                                 
   28     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function colortolum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d8m0m
function name:  colorToLum
number of ops:  10
compiled vars:  !0 = $r, !1 = $g, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   16     3        MUL                                              ~3      !0, 0.299
          4        MUL                                              ~4      !1, 0.587
          5        ADD                                              ~5      ~3, ~4
          6        MUL                                              ~6      !1, 0.114
          7        ADD                                              ~7      ~5, ~6
          8      > RETURN                                                   ~7
   17     9*     > RETURN                                                   null

End of function colortolum

Function %00%7Bclosure%7D%2Fin%2Fd8m0m%3A21%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d8m0m
function name:  {closure}
number of ops:  23
compiled vars:  !0 = $one, !1 = $two, !2 = $lumOne, !3 = $lumTwo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   22     2        INIT_FCALL                                               'colortolum'
          3        FETCH_DIM_R                                      ~4      !0, 0
          4        SEND_VAL                                                 ~4
          5        FETCH_DIM_R                                      ~5      !0, 1
          6        SEND_VAL                                                 ~5
          7        FETCH_DIM_R                                      ~6      !0, 2
          8        SEND_VAL                                                 ~6
          9        DO_FCALL                                      0  $7      
         10        ASSIGN                                                   !2, $7
   23    11        INIT_FCALL                                               'colortolum'
         12        FETCH_DIM_R                                      ~9      !1, 0
         13        SEND_VAL                                                 ~9
         14        FETCH_DIM_R                                      ~10     !1, 1
         15        SEND_VAL                                                 ~10
         16        FETCH_DIM_R                                      ~11     !1, 2
         17        SEND_VAL                                                 ~11
         18        DO_FCALL                                      0  $12     
         19        ASSIGN                                                   !3, $12
   24    20        SUB                                              ~14     !3, !2
         21      > RETURN                                                   ~14
   25    22*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fd8m0m%3A21%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.7 ms | 1403 KiB | 19 Q