3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=array( array("count"=>10,"date"=>"2014-04-16"), array("count"=>50,"date"=>"2014-04-18"), array("count"=>80,"date"=>"2014-04-20") ); $date =array("2014-04-16","2014-04-17","2014-04-18","2014-04-19","2014-04-20"); foreach($arr as $k =>$v ){ //if(!array_key_exists($v['date'],$date)){ // $arr[]=array("count"=>0,"date"=>$date) //} $tt[]=$v['date']; $new['date']=$v["count"]; } print_r(array_merge($date,$new)); foreach($arr as $k2 =>$v2 ){foreach($date as $k =>$v ){ if(!array_key_exists($v,$tt)){ $arr[]=array("count"=>0,"date"=>$v); } } } print_r($arr); //对应$date所有日期转换为 $arr=array( array("count"=>10,"date"=>"2014-04-16"), array("count"=>0,"date"=>"2014-04-17"), array("count"=>50,"date"=>"2014-04-18"), array("count"=>0,"date"=>"2014-04-19"), array("count"=>80,"date"=>"2014-04-20") );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 36
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 36
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 34
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 34
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 33
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 34
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 12
filename:       /in/nahp1
function name:  (null)
number of ops:  42
compiled vars:  !0 = $arr, !1 = $date, !2 = $v, !3 = $k, !4 = $tt, !5 = $new, !6 = $v2, !7 = $k2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   14     2      > FE_RESET_R                                       $10     !0, ->12
          3    > > FE_FETCH_R                                       ~11     $10, !2, ->12
          4    >   ASSIGN                                                   !3, ~11
   18     5        FETCH_DIM_R                                      ~14     !2, 'date'
          6        ASSIGN_DIM                                               !4
          7        OP_DATA                                                  ~14
   19     8        FETCH_DIM_R                                      ~16     !2, 'count'
          9        ASSIGN_DIM                                               !5, 'date'
         10        OP_DATA                                                  ~16
   14    11      > JMP                                                      ->3
         12    >   FE_FREE                                                  $10
   22    13        INIT_FCALL                                               'print_r'
         14        INIT_FCALL                                               'array_merge'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !5
         17        DO_ICALL                                         $17     
         18        SEND_VAR                                                 $17
         19        DO_ICALL                                                 
   23    20      > FE_RESET_R                                       $19     !0, ->36
         21    > > FE_FETCH_R                                       ~20     $19, !6, ->36
         22    >   ASSIGN                                                   !7, ~20
         23      > FE_RESET_R                                       $22     !1, ->34
         24    > > FE_FETCH_R                                       ~23     $22, !2, ->34
         25    >   ASSIGN                                                   !3, ~23
   24    26        ARRAY_KEY_EXISTS                                 ~25     !2, !4
         27        BOOL_NOT                                         ~26     ~25
         28      > JMPZ                                                     ~26, ->33
   25    29    >   INIT_ARRAY                                       ~28     0, 'count'
         30        ADD_ARRAY_ELEMENT                                ~28     !2, 'date'
         31        ASSIGN_DIM                                               !0
         32        OP_DATA                                                  ~28
   23    33    > > JMP                                                      ->24
         34    >   FE_FREE                                                  $22
         35      > JMP                                                      ->21
         36    >   FE_FREE                                                  $19
   29    37        INIT_FCALL                                               'print_r'
         38        SEND_VAR                                                 !0
         39        DO_ICALL                                                 
   33    40        ASSIGN                                                   !0, <array>
   44    41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.97 ms | 1400 KiB | 17 Q