3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data[0] = array( 'time' => '1403071646', 'netin' => '17.75', 'netout' => '22.5' ); $data[1] = array( 'time' => '1403071647', 'netin' => '17.75', 'netout' => '22.5' ); $data[2] = array( 'time' => '1403071649', 'netin' => '17.75', 'netout' => '22.5' ); // trying to make lines 15-19 become the following: // $output .= "{'x':'".date('Y-m-d H:i:s', $stat->time)."','y':'".number_format(round($stat->netin) / 1024, 2)."','z':'".number_format(round($stat->netout) / 1024, 2)."'}"; function chart_data($data, $items) { $count = count($data); $i = 1; foreach ($data as $stat) { $output .= '{'; foreach ($items as $key => $func) { $output .= "'".$key."':'".$func($stat)."'"; } $output .= '}'; if ($i < $count) { $output .= ","; } $output .= "\n"; $i++; } echo $output; } $items = array( 'x' => function ($stat) { return date('Y-m-d H:i:s', $stat->time); }, 'y' => function ($stat) { return number_format(round($stat->netin) / 1024, 2); }, 'z' => function ($stat) { return number_format(round($stat->netout) / 1024, 2); } ); chart_data($data, $items);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SVLDT
function name:  (null)
number of ops:  18
compiled vars:  !0 = $data, !1 = $items
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN_DIM                                               !0, 0
          1        OP_DATA                                                  <array>
    4     2        ASSIGN_DIM                                               !0, 1
          3        OP_DATA                                                  <array>
    5     4        ASSIGN_DIM                                               !0, 2
          5        OP_DATA                                                  <array>
   30     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FSVLDT%3A30%240'
   32     7        INIT_ARRAY                                       ~6      ~5, 'x'
   33     8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FSVLDT%3A33%241'
   35     9        ADD_ARRAY_ELEMENT                                ~6      ~7, 'y'
   36    10        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FSVLDT%3A36%242'
   38    11        ADD_ARRAY_ELEMENT                                ~6      ~8, 'z'
   30    12        ASSIGN                                                   !1, ~6
   42    13        INIT_FCALL                                               'chart_data'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !1
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

Function chart_data:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 28
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 28
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 20
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 25
Branch analysis from position: 20
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/SVLDT
function name:  chart_data
number of ops:  31
compiled vars:  !0 = $data, !1 = $items, !2 = $count, !3 = $i, !4 = $stat, !5 = $output, !6 = $func, !7 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        COUNT                                            ~8      !0
          3        ASSIGN                                                   !2, ~8
   13     4        ASSIGN                                                   !3, 1
   14     5      > FE_RESET_R                                       $11     !0, ->28
          6    > > FE_FETCH_R                                               $11, !4, ->28
   15     7    >   ASSIGN_OP                                     8          !5, '%7B'
   16     8      > FE_RESET_R                                       $13     !1, ->20
          9    > > FE_FETCH_R                                       ~14     $13, !6, ->20
         10    >   ASSIGN                                                   !7, ~14
   17    11        CONCAT                                           ~16     '%27', !7
         12        CONCAT                                           ~17     ~16, '%27%3A%27'
         13        INIT_DYNAMIC_CALL                                        !6
         14        SEND_VAR_EX                                              !4
         15        DO_FCALL                                      0  $18     
         16        CONCAT                                           ~19     ~17, $18
         17        CONCAT                                           ~20     ~19, '%27'
         18        ASSIGN_OP                                     8          !5, ~20
   16    19      > JMP                                                      ->9
         20    >   FE_FREE                                                  $13
   19    21        ASSIGN_OP                                     8          !5, '%7D'
   20    22        IS_SMALLER                                               !3, !2
         23      > JMPZ                                                     ~23, ->25
   21    24    >   ASSIGN_OP                                     8          !5, '%2C'
   23    25    >   ASSIGN_OP                                     8          !5, '%0A'
   24    26        PRE_INC                                                  !3
   14    27      > JMP                                                      ->6
         28    >   FE_FREE                                                  $11
   27    29        ECHO                                                     !5
   28    30      > RETURN                                                   null

End of function chart_data

Function %00%7Bclosure%7D%2Fin%2FSVLDT%3A30%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SVLDT
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $stat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          3        FETCH_OBJ_R                                      ~1      !0, 'time'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   32     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FSVLDT%3A30%240

Function %00%7Bclosure%7D%2Fin%2FSVLDT%3A33%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SVLDT
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $stat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   34     1        INIT_FCALL                                               'number_format'
          2        INIT_FCALL                                               'round'
          3        FETCH_OBJ_R                                      ~1      !0, 'netin'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6        DIV                                              ~3      $2, 1024
          7        SEND_VAL                                                 ~3
          8        SEND_VAL                                                 2
          9        DO_ICALL                                         $4      
         10      > RETURN                                                   $4
   35    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FSVLDT%3A33%241

Function %00%7Bclosure%7D%2Fin%2FSVLDT%3A36%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SVLDT
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $stat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
   37     1        INIT_FCALL                                               'number_format'
          2        INIT_FCALL                                               'round'
          3        FETCH_OBJ_R                                      ~1      !0, 'netout'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6        DIV                                              ~3      $2, 1024
          7        SEND_VAL                                                 ~3
          8        SEND_VAL                                                 2
          9        DO_ICALL                                         $4      
         10      > RETURN                                                   $4
   38    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FSVLDT%3A36%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.7 ms | 1406 KiB | 20 Q