3v4l.org

run code in 300+ PHP versions simultaneously
<?php $PopulationOfTexas = array( 1999 => 20.56, // in millions 2000 => 21.56, 2001 => 22.56, 2002 => 23.56 ); //generate an array sohwing the difference in each year compared to the previous year $differneces = array(); $lastmonth = null; foreach($PopulationOfTexas as $k=>$v){ if(empty($lastmonth)){$lastmonth = $k; continue;} $differneces[$k] = $k - $lastmonth; $lastmonth = $k; } //print_r($differneces); //get the average difference per year $count = 0; $total = 0; foreach($differneces as $k=>$v){ $count++; $total += $v; } $average = number_format(($total/$count), 2); //print_r($average); //make a prediction $lastitem = array_pop($PopulationOfTexas); print_r($lastitem);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 15
filename:       /in/FUXL1
function name:  (null)
number of ops:  39
compiled vars:  !0 = $PopulationOfTexas, !1 = $differneces, !2 = $lastmonth, !3 = $v, !4 = $k, !5 = $count, !6 = $total, !7 = $average, !8 = $lastitem
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   12     2        ASSIGN                                                   !2, null
   13     3      > FE_RESET_R                                       $12     !0, ->15
          4    > > FE_FETCH_R                                       ~13     $12, !3, ->15
          5    >   ASSIGN                                                   !4, ~13
   14     6        ISSET_ISEMPTY_CV                                         !2
          7      > JMPZ                                                     ~15, ->10
          8    >   ASSIGN                                                   !2, !4
          9      > JMP                                                      ->4
   15    10    >   SUB                                              ~18     !4, !2
         11        ASSIGN_DIM                                               !1, !4
         12        OP_DATA                                                  ~18
   16    13        ASSIGN                                                   !2, !4
   13    14      > JMP                                                      ->4
         15    >   FE_FREE                                                  $12
   22    16        ASSIGN                                                   !5, 0
   23    17        ASSIGN                                                   !6, 0
   24    18      > FE_RESET_R                                       $22     !1, ->24
         19    > > FE_FETCH_R                                       ~23     $22, !3, ->24
         20    >   ASSIGN                                                   !4, ~23
   25    21        PRE_INC                                                  !5
   26    22        ASSIGN_OP                                     1          !6, !3
   24    23      > JMP                                                      ->19
         24    >   FE_FREE                                                  $22
   29    25        INIT_FCALL                                               'number_format'
         26        DIV                                              ~27     !6, !5
         27        SEND_VAL                                                 ~27
         28        SEND_VAL                                                 2
         29        DO_ICALL                                         $28     
         30        ASSIGN                                                   !7, $28
   34    31        INIT_FCALL                                               'array_pop'
         32        SEND_REF                                                 !0
         33        DO_ICALL                                         $30     
         34        ASSIGN                                                   !8, $30
   35    35        INIT_FCALL                                               'print_r'
         36        SEND_VAR                                                 !8
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
201.58 ms | 1400 KiB | 19 Q