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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.66 ms | 1400 KiB | 17 Q