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($final, $s['nom'])) { if(!isset($final[$s['nom']]['data'])) $final[$s['nom']]['data'] = array(); array_push($final[$s['nom']]['data'], $s['temp']); } else { array_push($final, $s['nom']); if(!isset($final[$s['nom']]['data'])) $final[$s['nom']]['data'] = array(); if(!isset($final[$s['nom']]['nom'])) $final[$s['nom']]['nom'] = $s['id']; 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 = 61
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 61
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 28
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 42
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 52
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 52
Branch analysis from position: 42
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
filename:       /in/CDNbc
function name:  (null)
number of ops:  66
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, ->61
          3    > > FE_FETCH_R                                               $5, !2, ->61
   11     4    >   INIT_FCALL                                               'in_array'
          5        SEND_VAR                                                 !1
          6        FETCH_DIM_R                                      ~6      !2, 'nom'
          7        SEND_VAL                                                 ~6
          8        DO_ICALL                                         $7      
          9      > JMPZ                                                     $7, ->28
   12    10    >   FETCH_DIM_R                                      ~8      !2, 'nom'
         11        FETCH_DIM_IS                                     ~9      !1, ~8
         12        ISSET_ISEMPTY_DIM_OBJ                         0  ~10     ~9, 'data'
         13        BOOL_NOT                                         ~11     ~10
         14      > JMPZ                                                     ~11, ->19
   13    15    >   FETCH_DIM_R                                      ~12     !2, 'nom'
         16        FETCH_DIM_W                                      $13     !1, ~12
         17        ASSIGN_DIM                                               $13, 'data'
         18        OP_DATA                                                  <array>
   14    19    >   INIT_FCALL                                               'array_push'
         20        FETCH_DIM_R                                      ~15     !2, 'nom'
         21        FETCH_DIM_W                                      $16     !1, ~15
         22        FETCH_DIM_W                                      $17     $16, 'data'
         23        SEND_REF                                                 $17
         24        FETCH_DIM_R                                      ~18     !2, 'temp'
         25        SEND_VAL                                                 ~18
         26        DO_ICALL                                                 
         27      > JMP                                                      ->60
   16    28    >   INIT_FCALL                                               'array_push'
         29        SEND_REF                                                 !1
         30        FETCH_DIM_R                                      ~20     !2, 'nom'
         31        SEND_VAL                                                 ~20
         32        DO_ICALL                                                 
   17    33        FETCH_DIM_R                                      ~22     !2, 'nom'
         34        FETCH_DIM_IS                                     ~23     !1, ~22
         35        ISSET_ISEMPTY_DIM_OBJ                         0  ~24     ~23, 'data'
         36        BOOL_NOT                                         ~25     ~24
         37      > JMPZ                                                     ~25, ->42
   18    38    >   FETCH_DIM_R                                      ~26     !2, 'nom'
         39        FETCH_DIM_W                                      $27     !1, ~26
         40        ASSIGN_DIM                                               $27, 'data'
         41        OP_DATA                                                  <array>
   19    42    >   FETCH_DIM_R                                      ~29     !2, 'nom'
         43        FETCH_DIM_IS                                     ~30     !1, ~29
         44        ISSET_ISEMPTY_DIM_OBJ                         0  ~31     ~30, 'nom'
         45        BOOL_NOT                                         ~32     ~31
         46      > JMPZ                                                     ~32, ->52
   20    47    >   FETCH_DIM_R                                      ~33     !2, 'nom'
         48        FETCH_DIM_R                                      ~36     !2, 'id'
         49        FETCH_DIM_W                                      $34     !1, ~33
         50        ASSIGN_DIM                                               $34, 'nom'
         51        OP_DATA                                                  ~36
   21    52    >   INIT_FCALL                                               'array_push'
         53        FETCH_DIM_R                                      ~37     !2, 'nom'
         54        FETCH_DIM_W                                      $38     !1, ~37
         55        FETCH_DIM_W                                      $39     $38, 'data'
         56        SEND_REF                                                 $39
         57        FETCH_DIM_R                                      ~40     !2, 'temp'
         58        SEND_VAL                                                 ~40
         59        DO_ICALL                                                 
   10    60    > > JMP                                                      ->3
         61    >   FE_FREE                                                  $5
   24    62        INIT_FCALL                                               'print_r'
         63        SEND_VAR                                                 !1
         64        DO_ICALL                                                 
         65      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.5 ms | 1400 KiB | 19 Q