3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_remove_null($input) { foreach ($input as &$value) { if (is_array($value)) { $value = array_remove_null($value); } } return array_filter($input, function($item){ return $item !== null && $item !== ''; }); } /** * Using https://www.php.net/manual/en/function.array-replace-recursive.php */ $array1 = [ "2020-12" => [ "Mois" => "2020-12", "Nbr vendus" => null, "CA TTC" => null, "number" => "1", ], "2021-01" => [ "Mois" => "2021-01", "Nbr vendus" => null, "CA TTC" => null, "number" => "2", ], ]; $array2 = [ "2020-12" => [ "Mois" => "2020-12", "Nbr vendus" => "1", "CA TTC" => "790", "number" => null, ], "2021-01" => [ "Mois" => "2021-01", "Nbr vendus" => "3", "CA TTC" => "1680", "number" => null, ], ]; $array = array_replace_recursive(array_remove_null($array1), array_remove_null($array2)); var_dump($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/WJnYu
function name:  (null)
number of ops:  17
compiled vars:  !0 = $array1, !1 = $array2, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   33     1        ASSIGN                                                   !1, <array>
   48     2        INIT_FCALL                                               'array_replace_recursive'
          3        INIT_FCALL                                               'array_remove_null'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $5      
          6        SEND_VAR                                                 $5
          7        INIT_FCALL                                               'array_remove_null'
          8        SEND_VAR                                                 !1
          9        DO_FCALL                                      0  $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !2, $7
   50    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function array_remove_null:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 10
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/WJnYu
function name:  array_remove_null
number of ops:  18
compiled vars:  !0 = $input, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1      > FE_RESET_RW                                      $2      !0, ->10
          2    > > FE_FETCH_RW                                              $2, !1, ->10
    5     3    >   TYPE_CHECK                                  128          !1
          4      > JMPZ                                                     ~3, ->9
    6     5    >   INIT_FCALL_BY_NAME                                       'array_remove_null'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $4      
          8        ASSIGN                                                   !1, $4
    4     9    > > JMP                                                      ->2
         10    >   FE_FREE                                                  $2
    9    11        INIT_FCALL                                               'array_filter'
         12        SEND_VAR                                                 !0
         13        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FWJnYu%3A9%240'
   11    14        SEND_VAL                                                 ~6
         15        DO_ICALL                                         $7      
         16      > RETURN                                                   $7
   12    17*     > RETURN                                                   null

End of function array_remove_null

Function %00%7Bclosure%7D%2Fin%2FWJnYu%3A9%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/WJnYu
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        TYPE_CHECK                                  1020  ~1      !0
          2      > JMPZ_EX                                          ~1      ~1, ->5
          3    >   IS_NOT_IDENTICAL                                 ~2      !0, ''
          4        BOOL                                             ~1      ~2
          5    > > RETURN                                                   ~1
   11     6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FWJnYu%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.5 ms | 1403 KiB | 21 Q