3v4l.org

run code in 300+ PHP versions simultaneously
<?php $price = array( ); $price = array ( "adult" => array(), "child" => array()); $price['adult'][1]['2014-05-01'] = array(); $price['adult'][1]['2014-05-01']['basic_price'] = 100.00; $price['child'][1]['2014-05-01'] = array(); $price['child'][1]['2014-05-01']['basic_price'] = 0.00; $price['child'][1]['2014-05-01']['hotel_child'] = 396; $price['child'][2]['2014-05-01'] = array(); $price['child'][2]['2014-05-01']['basic_price'] = 10.00; $price['child'][2]['2014-05-01']['hotel_child'] = 407; $occ[0]['bdate'] = '01.05.2006'; $occ[0]['hotel_child_id'] = 407; print "<pre> <h4>Childovi:</h4> <br>"; print_r($occ); print "</pre>"; #print "<pre> <h4>Price arra:</h4> <br>"; #print_r($price); #print "</pre>"; $child_id = 396; function chk($id, $arr) { foreach ($arr as $a => $v) { if ($v['hotel_child_id'] == $id) { return true; } } } foreach ($price as $pr => $val) { if ($pr == "child") { foreach ($val as $ch => $vv) { foreach ($vv as $d => $v) { if (chk($v['hotel_child'], $occ)) { print $v['hotel_child'] . "<br>"; } else { unset($price[$pr][$ch]); } } } } } print "Posle: <br><br> <pre>"; print_r($price); print "</pre>";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 52, Position 2 = 79
Branch analysis from position: 52
2 jumps found. (Code = 78) Position 1 = 53, Position 2 = 79
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 78
Branch analysis from position: 56
2 jumps found. (Code = 77) Position 1 = 57, Position 2 = 77
Branch analysis from position: 57
2 jumps found. (Code = 78) Position 1 = 58, Position 2 = 77
Branch analysis from position: 58
2 jumps found. (Code = 77) Position 1 = 60, Position 2 = 75
Branch analysis from position: 60
2 jumps found. (Code = 78) Position 1 = 61, Position 2 = 75
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 72
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 75
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
Branch analysis from position: 77
Branch analysis from position: 78
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 79
filename:       /in/gVekP
function name:  (null)
number of ops:  86
compiled vars:  !0 = $price, !1 = $occ, !2 = $child_id, !3 = $val, !4 = $pr, !5 = $vv, !6 = $ch, !7 = $v, !8 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !0, <array>
    7     2        FETCH_DIM_W                                      $11     !0, 'adult'
          3        FETCH_DIM_W                                      $12     $11, 1
          4        ASSIGN_DIM                                               $12, '2014-05-01'
          5        OP_DATA                                                  <array>
    8     6        FETCH_DIM_W                                      $14     !0, 'adult'
          7        FETCH_DIM_W                                      $15     $14, 1
          8        FETCH_DIM_W                                      $16     $15, '2014-05-01'
          9        ASSIGN_DIM                                               $16, 'basic_price'
         10        OP_DATA                                                  100
   10    11        FETCH_DIM_W                                      $18     !0, 'child'
         12        FETCH_DIM_W                                      $19     $18, 1
         13        ASSIGN_DIM                                               $19, '2014-05-01'
         14        OP_DATA                                                  <array>
   11    15        FETCH_DIM_W                                      $21     !0, 'child'
         16        FETCH_DIM_W                                      $22     $21, 1
         17        FETCH_DIM_W                                      $23     $22, '2014-05-01'
         18        ASSIGN_DIM                                               $23, 'basic_price'
         19        OP_DATA                                                  0
   12    20        FETCH_DIM_W                                      $25     !0, 'child'
         21        FETCH_DIM_W                                      $26     $25, 1
         22        FETCH_DIM_W                                      $27     $26, '2014-05-01'
         23        ASSIGN_DIM                                               $27, 'hotel_child'
         24        OP_DATA                                                  396
   14    25        FETCH_DIM_W                                      $29     !0, 'child'
         26        FETCH_DIM_W                                      $30     $29, 2
         27        ASSIGN_DIM                                               $30, '2014-05-01'
         28        OP_DATA                                                  <array>
   15    29        FETCH_DIM_W                                      $32     !0, 'child'
         30        FETCH_DIM_W                                      $33     $32, 2
         31        FETCH_DIM_W                                      $34     $33, '2014-05-01'
         32        ASSIGN_DIM                                               $34, 'basic_price'
         33        OP_DATA                                                  10
   16    34        FETCH_DIM_W                                      $36     !0, 'child'
         35        FETCH_DIM_W                                      $37     $36, 2
         36        FETCH_DIM_W                                      $38     $37, '2014-05-01'
         37        ASSIGN_DIM                                               $38, 'hotel_child'
         38        OP_DATA                                                  407
   18    39        FETCH_DIM_W                                      $40     !1, 0
         40        ASSIGN_DIM                                               $40, 'bdate'
         41        OP_DATA                                                  '01.05.2006'
   19    42        FETCH_DIM_W                                      $42     !1, 0
         43        ASSIGN_DIM                                               $42, 'hotel_child_id'
         44        OP_DATA                                                  407
   21    45        ECHO                                                     '%3Cpre%3E+%3Ch4%3EChildovi%3A%3C%2Fh4%3E+%3Cbr%3E'
   22    46        INIT_FCALL                                               'print_r'
         47        SEND_VAR                                                 !1
         48        DO_ICALL                                                 
   23    49        ECHO                                                     '%3C%2Fpre%3E'
   29    50        ASSIGN                                                   !2, 396
   39    51      > FE_RESET_R                                       $46     !0, ->79
         52    > > FE_FETCH_R                                       ~47     $46, !3, ->79
         53    >   ASSIGN                                                   !4, ~47
   40    54        IS_EQUAL                                                 !4, 'child'
         55      > JMPZ                                                     ~49, ->78
   41    56    > > FE_RESET_R                                       $50     !3, ->77
         57    > > FE_FETCH_R                                       ~51     $50, !5, ->77
         58    >   ASSIGN                                                   !6, ~51
   42    59      > FE_RESET_R                                       $53     !5, ->75
         60    > > FE_FETCH_R                                       ~54     $53, !7, ->75
         61    >   ASSIGN                                                   !8, ~54
   43    62        INIT_FCALL                                               'chk'
         63        FETCH_DIM_R                                      ~56     !7, 'hotel_child'
         64        SEND_VAL                                                 ~56
         65        SEND_VAR                                                 !1
         66        DO_FCALL                                      0  $57     
         67      > JMPZ                                                     $57, ->72
   44    68    >   FETCH_DIM_R                                      ~58     !7, 'hotel_child'
         69        CONCAT                                           ~59     ~58, '%3Cbr%3E'
         70        ECHO                                                     ~59
         71      > JMP                                                      ->74
   46    72    >   FETCH_DIM_UNSET                                  $60     !0, !4
         73        UNSET_DIM                                                $60, !6
   42    74    > > JMP                                                      ->60
         75    >   FE_FREE                                                  $53
   41    76      > JMP                                                      ->57
         77    >   FE_FREE                                                  $50
   39    78    > > JMP                                                      ->52
         79    >   FE_FREE                                                  $46
   54    80        ECHO                                                     'Posle%3A+%3Cbr%3E%3Cbr%3E+%3Cpre%3E'
   55    81        INIT_FCALL                                               'print_r'
         82        SEND_VAR                                                 !0
         83        DO_ICALL                                                 
   56    84        ECHO                                                     '%3C%2Fpre%3E'
         85      > RETURN                                                   1

Function chk:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/gVekP
function name:  chk
number of ops:  13
compiled vars:  !0 = $id, !1 = $arr, !2 = $v, !3 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2      > FE_RESET_R                                       $4      !1, ->11
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->11
          4    >   ASSIGN                                                   !3, ~5
   33     5        FETCH_DIM_R                                      ~7      !2, 'hotel_child_id'
          6        IS_EQUAL                                                 !0, ~7
          7      > JMPZ                                                     ~8, ->10
   34     8    >   FE_FREE                                                  $4
          9      > RETURN                                                   <true>
   32    10    > > JMP                                                      ->3
         11    >   FE_FREE                                                  $4
   37    12      > RETURN                                                   null

End of function chk

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.08 ms | 1407 KiB | 16 Q