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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.06 ms | 1400 KiB | 15 Q