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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.18 ms | 1400 KiB | 17 Q