3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = Array ( 0 => Array ( 0 => 'Max tide', 'marks_obt' => Array ( '0' => 2.00, '1' => 5.00 ), 'passing_marks' => Array ( '0' => 3.00, '1' => 3.00 ) ), 1 => Array ( 0 => 'David pixal', 'marks_obt' => Array ( '0' => 5.00, '1' => 5.00 ), 'passing_marks' => Array ( '0' => 3.00, '1' => 3.00 ) ) ); $finalOutput = array(); foreach ($data as $key => $value) { $innerArray = array(); $innerArray[] = array('data'=>$value[0],'style'=> 'background-color: red; text-align: center'); foreach($value['marks_obt'] as $k=>$v){ if( isset($value['passing_marks'][$k]) && $v > $value['passing_marks'][$k] ){ $innerArray[] = array('data'=>$v,'style'=> 'background-color: pink; text-align: center'); }else{ $innerArray[] = array('data'=>$v,'style'=> 'background-color: red; text-align: center'); } } $finalOutput[] = array('data'=> $innerArray); } print_r($finalOutput);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 38
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 38
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 33
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 33
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 22
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 33
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/p2aGD
function name:  (null)
number of ops:  43
compiled vars:  !0 = $data, !1 = $finalOutput, !2 = $value, !3 = $key, !4 = $innerArray, !5 = $v, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        ASSIGN                                                   !1, <array>
   38     2      > FE_RESET_R                                       $9      !0, ->38
          3    > > FE_FETCH_R                                       ~10     $9, !2, ->38
          4    >   ASSIGN                                                   !3, ~10
   39     5        ASSIGN                                                   !4, <array>
   40     6        FETCH_DIM_R                                      ~14     !2, 0
          7        INIT_ARRAY                                       ~15     ~14, 'data'
          8        ADD_ARRAY_ELEMENT                                ~15     'background-color%3A+red%3B+text-align%3A+center', 'style'
          9        ASSIGN_DIM                                               !4
         10        OP_DATA                                                  ~15
   41    11        FETCH_DIM_R                                      ~16     !2, 'marks_obt'
         12      > FE_RESET_R                                       $17     ~16, ->33
         13    > > FE_FETCH_R                                       ~18     $17, !5, ->33
         14    >   ASSIGN                                                   !6, ~18
   42    15        FETCH_DIM_IS                                     ~20     !2, 'passing_marks'
         16        ISSET_ISEMPTY_DIM_OBJ                         0  ~21     ~20, !6
         17      > JMPZ_EX                                          ~21     ~21, ->22
         18    >   FETCH_DIM_R                                      ~22     !2, 'passing_marks'
         19        FETCH_DIM_R                                      ~23     ~22, !6
         20        IS_SMALLER                                       ~24     ~23, !5
         21        BOOL                                             ~21     ~24
         22    > > JMPZ                                                     ~21, ->28
   43    23    >   INIT_ARRAY                                       ~26     !5, 'data'
         24        ADD_ARRAY_ELEMENT                                ~26     'background-color%3A+pink%3B+text-align%3A+center', 'style'
         25        ASSIGN_DIM                                               !4
         26        OP_DATA                                                  ~26
   42    27      > JMP                                                      ->32
   45    28    >   INIT_ARRAY                                       ~28     !5, 'data'
         29        ADD_ARRAY_ELEMENT                                ~28     'background-color%3A+red%3B+text-align%3A+center', 'style'
         30        ASSIGN_DIM                                               !4
         31        OP_DATA                                                  ~28
   41    32    > > JMP                                                      ->13
         33    >   FE_FREE                                                  $17
   48    34        INIT_ARRAY                                       ~30     !4, 'data'
         35        ASSIGN_DIM                                               !1
         36        OP_DATA                                                  ~30
   38    37      > JMP                                                      ->3
         38    >   FE_FREE                                                  $9
   51    39        INIT_FCALL                                               'print_r'
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                                 
         42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.69 ms | 1010 KiB | 14 Q