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']); print_r($final);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 42
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 42
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 36
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/3PMlU
function name:  (null)
number of ops:  47
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, ->42
          3    > > FE_FETCH_R                                               $5, !2, ->42
   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      > JMPZ                                                     $7, ->36
   12    10    >   FETCH_DIM_R                                      ~8      !2, 'nom'
         11        FETCH_DIM_R                                      ~9      !1, ~8
         12        FETCH_DIM_R                                      ~10     ~9, 'data'
         13        TYPE_CHECK                                  128  ~11     ~10
         14        BOOL_NOT                                         ~12     ~11
         15      > JMPZ                                                     ~12, ->20
   13    16    >   FETCH_DIM_R                                      ~13     !2, 'nom'
         17        FETCH_DIM_W                                      $14     !1, ~13
         18        ASSIGN_DIM                                               $14, 'data'
         19        OP_DATA                                                  <array>
   14    20    >   INIT_FCALL                                               'array_merge'
         21        FETCH_DIM_R                                      ~16     !2, 'nom'
         22        FETCH_DIM_R                                      ~17     !1, ~16
         23        CAST                                          7  ~18     ~17
         24        SEND_VAL                                                 ~18
         25        SEND_VAL                                                 <array>
         26        DO_ICALL                                                 
   15    27        INIT_FCALL                                               'array_push'
         28        FETCH_DIM_R                                      ~20     !2, 'nom'
         29        FETCH_DIM_W                                      $21     !1, ~20
         30        FETCH_DIM_W                                      $22     $21, 'data'
         31        SEND_REF                                                 $22
         32        FETCH_DIM_R                                      ~23     !2, 'temp'
         33        SEND_VAL                                                 ~23
         34        DO_ICALL                                                 
         35      > JMP                                                      ->41
   17    36    >   INIT_FCALL                                               'array_push'
         37        SEND_REF                                                 !1
         38        FETCH_DIM_R                                      ~25     !2, 'nom'
         39        SEND_VAL                                                 ~25
         40        DO_ICALL                                                 
   10    41    > > JMP                                                      ->3
         42    >   FE_FREE                                                  $5
   19    43        INIT_FCALL                                               'print_r'
         44        SEND_VAR                                                 !1
         45        DO_ICALL                                                 
         46      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.08 ms | 1400 KiB | 21 Q