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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.44 ms | 1400 KiB | 17 Q