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(); print_r(array_values(array_values($final))); foreach($sql as $s) { if( !in_array($s['nom'], array_values(array_values($final))) ) { array_push($final, array($s['nom'])); $i = array_search($s['nom'], $final); 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 = 12, Position 2 = 82
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 82
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 61
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 45
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 60
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 60
Branch analysis from position: 45
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 74
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 74
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 82
filename:       /in/O954S
function name:  (null)
number of ops:  87
compiled vars:  !0 = $sql, !1 = $final, !2 = $s, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   11     2        INIT_FCALL                                               'print_r'
          3        INIT_FCALL                                               'array_values'
          4        INIT_FCALL                                               'array_values'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                         $7      
          9        SEND_VAR                                                 $7
         10        DO_ICALL                                                 
   13    11      > FE_RESET_R                                       $9      !0, ->82
         12    > > FE_FETCH_R                                               $9, !2, ->82
   14    13    >   INIT_FCALL                                               'in_array'
         14        FETCH_DIM_R                                      ~10     !2, 'nom'
         15        SEND_VAL                                                 ~10
         16        INIT_FCALL                                               'array_values'
         17        INIT_FCALL                                               'array_values'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $11     
         20        SEND_VAR                                                 $11
         21        DO_ICALL                                         $12     
         22        SEND_VAR                                                 $12
         23        DO_ICALL                                         $13     
         24        BOOL_NOT                                         ~14     $13
         25      > JMPZ                                                     ~14, ->61
   15    26    >   INIT_FCALL                                               'array_push'
         27        SEND_REF                                                 !1
         28        FETCH_DIM_R                                      ~15     !2, 'nom'
         29        INIT_ARRAY                                       ~16     ~15
         30        SEND_VAL                                                 ~16
         31        DO_ICALL                                                 
   16    32        INIT_FCALL                                               'array_search'
         33        FETCH_DIM_R                                      ~18     !2, 'nom'
         34        SEND_VAL                                                 ~18
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                         $19     
         37        ASSIGN                                                   !3, $19
   18    38        FETCH_DIM_IS                                     ~21     !1, !3
         39        ISSET_ISEMPTY_DIM_OBJ                         0  ~22     ~21, 'data'
         40        BOOL_NOT                                         ~23     ~22
         41      > JMPZ                                                     ~23, ->45
   19    42    >   FETCH_DIM_W                                      $24     !1, !3
         43        ASSIGN_DIM                                               $24, 'data'
         44        OP_DATA                                                  <array>
   22    45    >   INIT_FCALL                                               'array_push'
         46        FETCH_DIM_W                                      $26     !1, !3
         47        FETCH_DIM_W                                      $27     $26, 'data'
         48        SEND_REF                                                 $27
         49        FETCH_DIM_R                                      ~28     !2, 'temp'
         50        SEND_VAL                                                 ~28
         51        DO_ICALL                                                 
   24    52        FETCH_DIM_IS                                     ~30     !1, !3
         53        ISSET_ISEMPTY_DIM_OBJ                         0  ~31     ~30, 'name'
         54        BOOL_NOT                                         ~32     ~31
         55      > JMPZ                                                     ~32, ->60
   25    56    >   FETCH_DIM_R                                      ~35     !2, 'id'
         57        FETCH_DIM_W                                      $33     !1, !3
         58        ASSIGN_DIM                                               $33, 'name'
         59        OP_DATA                                                  ~35
         60    > > JMP                                                      ->81
   28    61    >   INIT_FCALL                                               'array_search'
         62        FETCH_DIM_R                                      ~36     !2, 'nom'
         63        SEND_VAL                                                 ~36
         64        SEND_VAR                                                 !1
         65        DO_ICALL                                         $37     
         66        ASSIGN                                                   !3, $37
   29    67        FETCH_DIM_IS                                     ~39     !1, !3
         68        ISSET_ISEMPTY_DIM_OBJ                         0  ~40     ~39, 'data'
         69        BOOL_NOT                                         ~41     ~40
         70      > JMPZ                                                     ~41, ->74
   30    71    >   FETCH_DIM_W                                      $42     !1, !3
         72        ASSIGN_DIM                                               $42, 'data'
         73        OP_DATA                                                  <array>
   32    74    >   INIT_FCALL                                               'array_push'
         75        FETCH_DIM_W                                      $44     !1, !3
         76        FETCH_DIM_W                                      $45     $44, 'data'
         77        SEND_REF                                                 $45
         78        FETCH_DIM_R                                      ~46     !2, 'temp'
         79        SEND_VAL                                                 ~46
         80        DO_ICALL                                                 
   13    81    > > JMP                                                      ->12
         82    >   FE_FREE                                                  $9
   36    83        INIT_FCALL                                               'print_r'
         84        SEND_VAR                                                 !1
         85        DO_ICALL                                                 
         86      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.22 ms | 1404 KiB | 23 Q