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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.29 ms | 945 KiB | 24 Q