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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.05 ms | 1404 KiB | 23 Q