3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array=array("number"=>"3","string"=>"abc","null"=>null); $ncache=array(); $scache=array(); foreach(range(1,10000) as $it) { $ncache[]=$array; $scache[]=$array; } function ncompress(&$v) { if(is_numeric($v)) $v=floatval($v); elseif(is_string($v)) $v=trim($v); elseif(is_null($v)) $v=null; } function scompress(&$v) { if(is_numeric($v)) $v=floatval($v); elseif(is_string($v)) $v=trim($v); elseif(is_null($v)) $v=""; } array_walk_recursive($ncache,"ncompress"); array_walk_recursive($scache,"scompress"); echo "Length of null : ".strlen(json_encode($ncache)) .' ('.strlen(gzdeflate(json_encode($ncache))).')' .' ('.strlen(gzencode(json_encode($ncache),9)).')'; echo "\n"; echo "Length of string: ".strlen(json_encode($scache)) .' ('.strlen(gzdeflate(json_encode($scache))).')' .' ('.strlen(gzencode(json_encode($scache),9)).')';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/WZeQH
function name:  (null)
number of ops:  79
compiled vars:  !0 = $array, !1 = $ncache, !2 = $scache, !3 = $it
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    4     2        ASSIGN                                                   !2, <array>
    5     3        INIT_FCALL                                               'range'
          4        SEND_VAL                                                 1
          5        SEND_VAL                                                 10000
          6        DO_ICALL                                         $7      
          7      > FE_RESET_R                                       $8      $7, ->14
          8    > > FE_FETCH_R                                               $8, !3, ->14
    7     9    >   ASSIGN_DIM                                               !1
         10        OP_DATA                                                  !0
    8    11        ASSIGN_DIM                                               !2
         12        OP_DATA                                                  !0
    5    13      > JMP                                                      ->8
         14    >   FE_FREE                                                  $8
   22    15        INIT_FCALL                                               'array_walk_recursive'
         16        SEND_REF                                                 !1
         17        SEND_VAL                                                 'ncompress'
         18        DO_ICALL                                                 
   23    19        INIT_FCALL                                               'array_walk_recursive'
         20        SEND_REF                                                 !2
         21        SEND_VAL                                                 'scompress'
         22        DO_ICALL                                                 
   24    23        INIT_FCALL                                               'json_encode'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $13     
         26        STRLEN                                           ~14     $13
         27        CONCAT                                           ~15     'Length+of+null++%3A+', ~14
   25    28        CONCAT                                           ~16     ~15, '+%28'
         29        INIT_FCALL                                               'gzdeflate'
         30        INIT_FCALL                                               'json_encode'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                         $17     
         33        SEND_VAR                                                 $17
         34        DO_ICALL                                         $18     
         35        STRLEN                                           ~19     $18
         36        CONCAT                                           ~20     ~16, ~19
         37        CONCAT                                           ~21     ~20, '%29'
   26    38        CONCAT                                           ~22     ~21, '+%28'
         39        INIT_FCALL                                               'gzencode'
         40        INIT_FCALL                                               'json_encode'
         41        SEND_VAR                                                 !1
         42        DO_ICALL                                         $23     
         43        SEND_VAR                                                 $23
         44        SEND_VAL                                                 9
         45        DO_ICALL                                         $24     
         46        STRLEN                                           ~25     $24
         47        CONCAT                                           ~26     ~22, ~25
         48        CONCAT                                           ~27     ~26, '%29'
         49        ECHO                                                     ~27
   27    50        ECHO                                                     '%0A'
   28    51        INIT_FCALL                                               'json_encode'
         52        SEND_VAR                                                 !2
         53        DO_ICALL                                         $28     
         54        STRLEN                                           ~29     $28
         55        CONCAT                                           ~30     'Length+of+string%3A+', ~29
   29    56        CONCAT                                           ~31     ~30, '+%28'
         57        INIT_FCALL                                               'gzdeflate'
         58        INIT_FCALL                                               'json_encode'
         59        SEND_VAR                                                 !2
         60        DO_ICALL                                         $32     
         61        SEND_VAR                                                 $32
         62        DO_ICALL                                         $33     
         63        STRLEN                                           ~34     $33
         64        CONCAT                                           ~35     ~31, ~34
         65        CONCAT                                           ~36     ~35, '%29'
   30    66        CONCAT                                           ~37     ~36, '+%28'
         67        INIT_FCALL                                               'gzencode'
         68        INIT_FCALL                                               'json_encode'
         69        SEND_VAR                                                 !2
         70        DO_ICALL                                         $38     
         71        SEND_VAR                                                 $38
         72        SEND_VAL                                                 9
         73        DO_ICALL                                         $39     
         74        STRLEN                                           ~40     $39
         75        CONCAT                                           ~41     ~37, ~40
         76        CONCAT                                           ~42     ~41, '%29'
         77        ECHO                                                     ~42
         78      > RETURN                                                   1

Function ncompress:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/WZeQH
function name:  ncompress
number of ops:  19
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'is_numeric'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > JMPZ                                                     $1, ->8
          5    >   CAST                                          5  ~2      !0
          6        ASSIGN                                                   !0, ~2
          7      > JMP                                                      ->18
   13     8    >   TYPE_CHECK                                   64          !0
          9      > JMPZ                                                     ~4, ->15
         10    >   INIT_FCALL                                               'trim'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        ASSIGN                                                   !0, $5
         14      > JMP                                                      ->18
   14    15    >   TYPE_CHECK                                    2          !0
         16      > JMPZ                                                     ~7, ->18
         17    >   ASSIGN                                                   !0, null
   15    18    > > RETURN                                                   null

End of function ncompress

Function scompress:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/WZeQH
function name:  scompress
number of ops:  19
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'is_numeric'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > JMPZ                                                     $1, ->8
          5    >   CAST                                          5  ~2      !0
          6        ASSIGN                                                   !0, ~2
          7      > JMP                                                      ->18
   19     8    >   TYPE_CHECK                                   64          !0
          9      > JMPZ                                                     ~4, ->15
         10    >   INIT_FCALL                                               'trim'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        ASSIGN                                                   !0, $5
         14      > JMP                                                      ->18
   20    15    >   TYPE_CHECK                                    2          !0
         16      > JMPZ                                                     ~7, ->18
         17    >   ASSIGN                                                   !0, ''
   21    18    > > RETURN                                                   null

End of function scompress

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.5 ms | 1408 KiB | 27 Q