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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.15 ms | 1392 KiB | 23 Q