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[$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 = 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 = 56
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 56
Branch analysis from position: 42
2 jumps found. (Code = 77) Position 1 = 44, Position 2 = 54
Branch analysis from position: 44
2 jumps found. (Code = 78) Position 1 = 45, Position 2 = 54
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 53
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
Branch analysis from position: 53
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 54
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
Branch analysis from position: 36
Branch analysis from position: 16
filename:       /in/OEiAT
function name:  (null)
number of ops:  62
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, !8
         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     !0, ->56
         41    > > FE_FETCH_R                                       ~32     $31, !7, ->56
         42    >   ASSIGN                                                   !8, ~32
         43      > FE_RESET_R                                       $34     !1, ->54
         44    > > FE_FETCH_R                                       ~35     $34, !2, ->54
         45    >   ASSIGN                                                   !3, ~35
   29    46        ARRAY_KEY_EXISTS                                 ~37     !2, !4
         47        BOOL_NOT                                         ~38     ~37
         48      > JMPZ                                                     ~38, ->53
   30    49    >   INIT_ARRAY                                       ~40     0, 'count'
         50        ADD_ARRAY_ELEMENT                                ~40     !2, 'date'
         51        ASSIGN_DIM                                               !0
         52        OP_DATA                                                  ~40
   28    53    > > JMP                                                      ->44
         54    >   FE_FREE                                                  $34
         55      > JMP                                                      ->41
         56    >   FE_FREE                                                  $31
   34    57        INIT_FCALL                                               'print_r'
         58        SEND_VAR                                                 !0
         59        DO_ICALL                                                 
   38    60        ASSIGN                                                   !0, <array>
   49    61      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.92 ms | 1392 KiB | 17 Q