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'];$cc[]=$v['count']; $new['date']=$v["count"]; } print_r(array_combine($date,$new)); //foreach($new as $k =>$v){ foreach($date as $k2 =>$v2 ){ if(!array_key_exists($v2,$new)){$new[$k2]=0;} }print_r($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 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 32
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 31
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 52
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 52
Branch analysis from position: 38
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 50
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 50
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 49
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 49
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 50
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
Branch analysis from position: 32
Branch analysis from position: 15
filename:       /in/L184D
function name:  (null)
number of ops:  58
compiled vars:  !0 = $arr, !1 = $date, !2 = $v, !3 = $k, !4 = $tt, !5 = $cc, !6 = $new, !7 = $v2, !8 = $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                                       $11     !0, ->15
          3    > > FE_FETCH_R                                       ~12     $11, !2, ->15
          4    >   ASSIGN                                                   !3, ~12
   18     5        FETCH_DIM_R                                      ~15     !2, 'date'
          6        ASSIGN_DIM                                               !4
          7        OP_DATA                                                  ~15
          8        FETCH_DIM_R                                      ~17     !2, 'count'
          9        ASSIGN_DIM                                               !5
         10        OP_DATA                                                  ~17
   19    11        FETCH_DIM_R                                      ~19     !2, 'count'
         12        ASSIGN_DIM                                               !6, 'date'
         13        OP_DATA                                                  ~19
   14    14      > JMP                                                      ->3
         15    >   FE_FREE                                                  $11
   22    16        INIT_FCALL                                               'print_r'
         17        INIT_FCALL                                               'array_combine'
         18        SEND_VAR                                                 !1
         19        SEND_VAR                                                 !6
         20        DO_ICALL                                         $20     
         21        SEND_VAR                                                 $20
         22        DO_ICALL                                                 
   24    23      > FE_RESET_R                                       $22     !1, ->32
         24    > > FE_FETCH_R                                       ~23     $22, !7, ->32
         25    >   ASSIGN                                                   !8, ~23
   25    26        ARRAY_KEY_EXISTS                                 ~25     !7, !6
         27        BOOL_NOT                                         ~26     ~25
         28      > JMPZ                                                     ~26, ->31
         29    >   ASSIGN_DIM                                               !6, !8
         30        OP_DATA                                                  0
   24    31    > > JMP                                                      ->24
         32    >   FE_FREE                                                  $22
   26    33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !6
         35        DO_ICALL                                                 
   28    36      > FE_RESET_R                                       $29     !0, ->52
         37    > > FE_FETCH_R                                       ~30     $29, !7, ->52
         38    >   ASSIGN                                                   !8, ~30
         39      > FE_RESET_R                                       $32     !1, ->50
         40    > > FE_FETCH_R                                       ~33     $32, !2, ->50
         41    >   ASSIGN                                                   !3, ~33
   29    42        ARRAY_KEY_EXISTS                                 ~35     !2, !4
         43        BOOL_NOT                                         ~36     ~35
         44      > JMPZ                                                     ~36, ->49
   30    45    >   INIT_ARRAY                                       ~38     0, 'count'
         46        ADD_ARRAY_ELEMENT                                ~38     !2, 'date'
         47        ASSIGN_DIM                                               !0
         48        OP_DATA                                                  ~38
   28    49    > > JMP                                                      ->40
         50    >   FE_FREE                                                  $32
         51      > JMP                                                      ->37
         52    >   FE_FREE                                                  $29
   34    53        INIT_FCALL                                               'print_r'
         54        SEND_VAR                                                 !0
         55        DO_ICALL                                                 
   38    56        ASSIGN                                                   !0, <array>
   49    57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.01 ms | 1392 KiB | 17 Q