3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sql = array(array('id' => 0, 'nom' => 'A', 'temp' => 1.1, 'autre' => 0), array('id' => 1, 'nom' => 'A', 'temp' => 2.1, 'autre' => 10), array('id' => 2, 'nom' => 'A', 'temp' => 3.1, 'autre' => 20), array('id' => 3, 'nom' => 'B', 'temp' => 4.1, 'autre' => 30), array('id' => 4, 'nom' => 'C', 'temp' => 5.1, 'autre' => 40), array('id' => 5, 'nom' => 'B', 'temp' => 6.1, 'autre' => 50), array('id' => 6, 'nom' => 'A', 'temp' => 7.1, 'autre' => 60)); $final = array(); foreach ($sql as $s) if(!in_array($s['nom'], $final)) { if(!is_array($final[$s['nom']]['data'])) $final[$s['nom']]['data'] = array(); array_merge((array)$final[$s['nom']], array('data')); array_push($final[$s['nom']]['data'], $s['temp']); } else array_push($final[$s['nom']]['data'], $s['temp']); print_r($final);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 46
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 46
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 37
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
filename:       /in/i08AV
function name:  (null)
number of ops:  51
compiled vars:  !0 = $sql, !1 = $final, !2 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   10     2      > FE_RESET_R                                       $5      !0, ->46
          3    > > FE_FETCH_R                                               $5, !2, ->46
   11     4    >   INIT_FCALL                                               'in_array'
          5        FETCH_DIM_R                                      ~6      !2, 'nom'
          6        SEND_VAL                                                 ~6
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9        BOOL_NOT                                         ~8      $7
         10      > JMPZ                                                     ~8, ->37
   12    11    >   FETCH_DIM_R                                      ~9      !2, 'nom'
         12        FETCH_DIM_R                                      ~10     !1, ~9
         13        FETCH_DIM_R                                      ~11     ~10, 'data'
         14        TYPE_CHECK                                  128  ~12     ~11
         15        BOOL_NOT                                         ~13     ~12
         16      > JMPZ                                                     ~13, ->21
   13    17    >   FETCH_DIM_R                                      ~14     !2, 'nom'
         18        FETCH_DIM_W                                      $15     !1, ~14
         19        ASSIGN_DIM                                               $15, 'data'
         20        OP_DATA                                                  <array>
   14    21    >   INIT_FCALL                                               'array_merge'
         22        FETCH_DIM_R                                      ~17     !2, 'nom'
         23        FETCH_DIM_R                                      ~18     !1, ~17
         24        CAST                                          7  ~19     ~18
         25        SEND_VAL                                                 ~19
         26        SEND_VAL                                                 <array>
         27        DO_ICALL                                                 
   15    28        INIT_FCALL                                               'array_push'
         29        FETCH_DIM_R                                      ~21     !2, 'nom'
         30        FETCH_DIM_W                                      $22     !1, ~21
         31        FETCH_DIM_W                                      $23     $22, 'data'
         32        SEND_REF                                                 $23
         33        FETCH_DIM_R                                      ~24     !2, 'temp'
         34        SEND_VAL                                                 ~24
         35        DO_ICALL                                                 
         36      > JMP                                                      ->45
   17    37    >   INIT_FCALL                                               'array_push'
         38        FETCH_DIM_R                                      ~26     !2, 'nom'
         39        FETCH_DIM_W                                      $27     !1, ~26
         40        FETCH_DIM_W                                      $28     $27, 'data'
         41        SEND_REF                                                 $28
         42        FETCH_DIM_R                                      ~29     !2, 'temp'
         43        SEND_VAL                                                 ~29
         44        DO_ICALL                                                 
   10    45    > > JMP                                                      ->3
         46    >   FE_FREE                                                  $5
   19    47        INIT_FCALL                                               'print_r'
         48        SEND_VAR                                                 !1
         49        DO_ICALL                                                 
         50      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.53 ms | 1400 KiB | 21 Q