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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.21 ms | 1409 KiB | 21 Q