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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.9 ms | 1400 KiB | 23 Q