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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
195.49 ms | 1404 KiB | 23 Q