3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ (object) ['graduateYear' => 'Class of 2007', 'id' => 1, 'lastsName' => 'Igbashio', 'firstName' => 'Kalifort'], (object) ['graduateYear' => 'Class of 2007', 'id' => 2, 'lastsName' => 'Usman', 'firstName' => 'Bello'], (object) ['graduateYear' => 'Class of 2007', 'id' => 3, 'lastsName' => 'Manasseh', 'firstName' => 'Isa'], (object) ['graduateYear' => 'Class of 2008', 'id' => 4, 'lastsName' => 'Igbashio', 'firstName' => 'Sansa'], (object) ['graduateYear' => 'Class of 2008', 'id' => 5, 'lastsName' => 'Yusuf', 'firstName' => "Sa'atu"], (object) ['graduateYear' => 'Class of 2008', 'id' => 6, 'lastsName' => 'Rimamtse', 'firstName' => 'Bleesing'], ]; $grouped = []; foreach ($array as $obj) { sscanf($obj->graduateYear, 'Class of %d', $year); unset($obj->graduateYear); $grouped[$year]['title'] = $year; // doesn't matter that this is overwritten over and over $grouped[$year]['data'][] = $obj; } var_export(array_values($grouped));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 31
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 31
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/gBJWh
function name:  (null)
number of ops:  39
compiled vars:  !0 = $array, !1 = $grouped, !2 = $obj, !3 = $year
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   CAST                                          8  ~4      <array>
          1        INIT_ARRAY                                       ~5      ~4
    5     2        CAST                                          8  ~6      <array>
          3        ADD_ARRAY_ELEMENT                                ~5      ~6
    6     4        CAST                                          8  ~7      <array>
          5        ADD_ARRAY_ELEMENT                                ~5      ~7
    7     6        CAST                                          8  ~8      <array>
          7        ADD_ARRAY_ELEMENT                                ~5      ~8
    8     8        CAST                                          8  ~9      <array>
          9        ADD_ARRAY_ELEMENT                                ~5      ~9
    9    10        CAST                                          8  ~10     <array>
         11        ADD_ARRAY_ELEMENT                                ~5      ~10
    3    12        ASSIGN                                                   !0, ~5
   12    13        ASSIGN                                                   !1, <array>
   13    14      > FE_RESET_R                                       $13     !0, ->31
         15    > > FE_FETCH_R                                               $13, !2, ->31
   14    16    >   INIT_FCALL                                               'sscanf'
         17        FETCH_OBJ_R                                      ~14     !2, 'graduateYear'
         18        SEND_VAL                                                 ~14
         19        SEND_VAL                                                 'Class+of+%25d'
         20        SEND_REF                                                 !3
         21        DO_ICALL                                                 
   15    22        UNSET_OBJ                                                !2, 'graduateYear'
   16    23        FETCH_DIM_W                                      $16     !1, !3
         24        ASSIGN_DIM                                               $16, 'title'
         25        OP_DATA                                                  !3
   17    26        FETCH_DIM_W                                      $18     !1, !3
         27        FETCH_DIM_W                                      $19     $18, 'data'
         28        ASSIGN_DIM                                               $19
         29        OP_DATA                                                  !2
   13    30      > JMP                                                      ->15
         31    >   FE_FREE                                                  $13
   19    32        INIT_FCALL                                               'var_export'
         33        INIT_FCALL                                               'array_values'
         34        SEND_VAR                                                 !1
         35        DO_ICALL                                         $21     
         36        SEND_VAR                                                 $21
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.55 ms | 1013 KiB | 16 Q