3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_average ($t) { return array_sum($t)/sizeof ($t); } function note ($t) { return array_average ($t) - stats_standard_deviation ($t); } if (!function_exists('stats_standard_deviation')) { function stats_standard_deviation(array $a, $sample = false) { $n = count($a); if ($n === 0) {trigger_error("The array has zero elements", E_USER_WARNING); return false; } if ($sample && $n === 1) { trigger_error("The array has 1 element", E_USER_WARNING);return false;} $mean = array_sum($a) / $n; $carry = 0.0; foreach ($a as $val) { $d = ((double) $val) - $mean; $carry += $d * $d; }; if ($sample) {--$n;} return sqrt($carry / $n); } } $tableau1 = [6,6,6,0,0]; $tableau2 = [3,3,3,4,4]; echo "En prenant en compte la moyenne\n"; echo "tableau1 = ".array_average ($tableau1)."\n"; echo "tableau2 = ".array_average ($tableau2)."\n"; if (array_average ($tableau1)>array_average ($tableau2)) echo "tableau 1 a une meilleure moyenne."; else echo "tableau 2 a une meilleure moyenne."; echo "\n";echo "\n"; echo "En prenant en compte la moyenne - écart_type\n"; echo "tableau1 = ".note ($tableau1)."\n"; echo "tableau2 = ".note ($tableau2)."\n"; if (note ($tableau1)>note ($tableau2)) echo "tableau 1 a une meilleure note (moyenne-écart_type)."; else echo "tableau 2 a une meilleure note (moyenne - écart_type)."; echo "\n"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 57
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 57
Branch analysis from position: 55
Branch analysis from position: 57
Branch analysis from position: 6
filename:       /in/647Fd
function name:  (null)
number of ops:  60
compiled vars:  !0 = $tableau1, !1 = $tableau2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'stats_standard_deviation'
          2        DO_ICALL                                         $2      
          3        BOOL_NOT                                         ~3      $2
          4      > JMPZ                                                     ~3, ->6
    6     5    >   DECLARE_FUNCTION                                         'stats_standard_deviation'
   23     6    >   ASSIGN                                                   !0, <array>
   24     7        ASSIGN                                                   !1, <array>
   25     8        ECHO                                                     'En+prenant+en+compte+la+moyenne%0A'
   26     9        INIT_FCALL                                               'array_average'
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0  $6      
         12        CONCAT                                           ~7      'tableau1+%3D+', $6
         13        CONCAT                                           ~8      ~7, '%0A'
         14        ECHO                                                     ~8
   27    15        INIT_FCALL                                               'array_average'
         16        SEND_VAR                                                 !1
         17        DO_FCALL                                      0  $9      
         18        CONCAT                                           ~10     'tableau2+%3D+', $9
         19        CONCAT                                           ~11     ~10, '%0A'
         20        ECHO                                                     ~11
   28    21        INIT_FCALL                                               'array_average'
         22        SEND_VAR                                                 !0
         23        DO_FCALL                                      0  $12     
         24        INIT_FCALL                                               'array_average'
         25        SEND_VAR                                                 !1
         26        DO_FCALL                                      0  $13     
         27        IS_SMALLER                                               $13, $12
         28      > JMPZ                                                     ~14, ->31
   29    29    >   ECHO                                                     'tableau+1+a+une+meilleure+moyenne.'
   28    30      > JMP                                                      ->32
   31    31    >   ECHO                                                     'tableau+2+a+une+meilleure+moyenne.'
   32    32    >   ECHO                                                     '%0A'
         33        ECHO                                                     '%0A'
   34    34        ECHO                                                     'En+prenant+en+compte+la+moyenne+-+%C3%A9cart_type%0A'
   35    35        INIT_FCALL                                               'note'
         36        SEND_VAR                                                 !0
         37        DO_FCALL                                      0  $15     
         38        CONCAT                                           ~16     'tableau1+%3D+', $15
         39        CONCAT                                           ~17     ~16, '%0A'
         40        ECHO                                                     ~17
   36    41        INIT_FCALL                                               'note'
         42        SEND_VAR                                                 !1
         43        DO_FCALL                                      0  $18     
         44        CONCAT                                           ~19     'tableau2+%3D+', $18
         45        CONCAT                                           ~20     ~19, '%0A'
         46        ECHO                                                     ~20
   37    47        INIT_FCALL                                               'note'
         48        SEND_VAR                                                 !0
         49        DO_FCALL                                      0  $21     
         50        INIT_FCALL                                               'note'
         51        SEND_VAR                                                 !1
         52        DO_FCALL                                      0  $22     
         53        IS_SMALLER                                               $22, $21
         54      > JMPZ                                                     ~23, ->57
   38    55    >   ECHO                                                     'tableau+1+a+une+meilleure+note+%28moyenne-%C3%A9cart_type%29.'
   37    56      > JMP                                                      ->58
   40    57    >   ECHO                                                     'tableau+2+a+une+meilleure+note+%28moyenne+-+%C3%A9cart_type%29.'
   41    58    >   ECHO                                                     '%0A'
   43    59      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 34
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 37
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 34
Branch analysis from position: 14
filename:       /in/647Fd
function name:  stats_standard_deviation
number of ops:  43
compiled vars:  !0 = $a, !1 = $sample, !2 = $n, !3 = $mean, !4 = $carry, !5 = $val, !6 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <false>
    8     2        COUNT                                            ~7      !0
          3        ASSIGN                                                   !2, ~7
    9     4        IS_IDENTICAL                                             !2, 0
          5      > JMPZ                                                     ~9, ->11
          6    >   INIT_FCALL                                               'trigger_error'
          7        SEND_VAL                                                 'The+array+has+zero+elements'
          8        SEND_VAL                                                 512
          9        DO_ICALL                                                 
         10      > RETURN                                                   <false>
   10    11    > > JMPZ_EX                                          ~11     !1, ->14
         12    >   IS_IDENTICAL                                     ~12     !2, 1
         13        BOOL                                             ~11     ~12
         14    > > JMPZ                                                     ~11, ->20
         15    >   INIT_FCALL                                               'trigger_error'
         16        SEND_VAL                                                 'The+array+has+1+element'
         17        SEND_VAL                                                 512
         18        DO_ICALL                                                 
         19      > RETURN                                                   <false>
   11    20    >   INIT_FCALL                                               'array_sum'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $14     
         23        DIV                                              ~15     $14, !2
         24        ASSIGN                                                   !3, ~15
   12    25        ASSIGN                                                   !4, 0
   13    26      > FE_RESET_R                                       $18     !0, ->34
         27    > > FE_FETCH_R                                               $18, !5, ->34
   15    28    >   CAST                                          5  ~19     !5
         29        SUB                                              ~20     ~19, !3
         30        ASSIGN                                                   !6, ~20
   16    31        MUL                                              ~22     !6, !6
         32        ASSIGN_OP                                     1          !4, ~22
   13    33      > JMP                                                      ->27
         34    >   FE_FREE                                                  $18
   18    35      > JMPZ                                                     !1, ->37
         36    >   PRE_DEC                                                  !2
   19    37    >   INIT_FCALL                                               'sqrt'
         38        DIV                                              ~25     !4, !2
         39        SEND_VAL                                                 ~25
         40        DO_ICALL                                         $26     
         41      > RETURN                                                   $26
   20    42*     > RETURN                                                   null

End of Dynamic Function 0

Function array_average:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/647Fd
function name:  array_average
number of ops:  8
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'array_sum'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        COUNT                                            ~2      !0
          5        DIV                                              ~3      $1, ~2
          6      > RETURN                                                   ~3
          7*     > RETURN                                                   null

End of function array_average

Function note:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/647Fd
function name:  note
number of ops:  10
compiled vars:  !0 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'array_average'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $1      
          4        INIT_FCALL_BY_NAME                                       'stats_standard_deviation'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $2      
          7        SUB                                              ~3      $1, $2
          8      > RETURN                                                   ~3
          9*     > RETURN                                                   null

End of function note

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.19 ms | 1016 KiB | 26 Q