3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array (0, 1, 1, 2, 0.5, 0.5); $counts = array_count_values(array_map('strval', $array)); $mode = array_search(max($counts), $counts); echo $mode; echo PHP_EOL; var_dump(isBiModal($counts)); function isBiModal($counts) { $match = max($counts); $filtered = array_filter($counts, function($el) use($match) { return $el === $match; }); return count($filtered) > 1; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cca5q
function name:  (null)
number of ops:  26
compiled vars:  !0 = $array, !1 = $counts, !2 = $mode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'array_count_values'
          2        INIT_FCALL                                               'array_map'
          3        SEND_VAL                                                 'strval'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !1, $5
    6     9        INIT_FCALL                                               'array_search'
         10        INIT_FCALL                                               'max'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $7      
         13        SEND_VAR                                                 $7
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $8      
         16        ASSIGN                                                   !2, $8
    7    17        ECHO                                                     !2
    8    18        ECHO                                                     '%0A'
    9    19        INIT_FCALL                                               'var_dump'
         20        INIT_FCALL_BY_NAME                                       'isBiModal'
         21        SEND_VAR_EX                                              !1
         22        DO_FCALL                                      0  $10     
         23        SEND_VAR                                                 $10
         24        DO_ICALL                                                 
   15    25      > RETURN                                                   1

Function isbimodal:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cca5q
function name:  isBiModal
number of ops:  16
compiled vars:  !0 = $counts, !1 = $match, !2 = $filtered
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'max'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   13     5        INIT_FCALL                                               'array_filter'
          6        SEND_VAR                                                 !0
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FCca5q%3A13%240'
          8        BIND_LEXICAL                                             ~5, !1
          9        SEND_VAL                                                 ~5
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !2, $6
   14    12        COUNT                                            ~8      !2
         13        IS_SMALLER                                       ~9      1, ~8
         14      > RETURN                                                   ~9
   15    15*     > RETURN                                                   null

End of function isbimodal

Function %00%7Bclosure%7D%2Fin%2FCca5q%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cca5q
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $el, !1 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        IS_IDENTICAL                                     ~2      !0, !1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FCca5q%3A13%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.68 ms | 1400 KiB | 25 Q