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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.43 ms | 1400 KiB | 17 Q