3v4l.org

run code in 300+ PHP versions simultaneously
<?php $postArray = array ( 0 => array ( 'id' => 1, 'post' => 'hello', 'userId' => 1, 'fileName' => 'hey.jpg', 'time' => 0, ), 1 => array ( 'id' => 1, 'post' => 'hello', 'userId' => 1, 'fileName' => 'test.png', 'time' => 53252354, ), 2 => array ( 'id' => 2, 'post' => 'world', 'userId' => 1, 'fileName' => 'asd.png', 'time' => 0, ), 3 => array ( 'id' => 4, 'post' => 'test', 'userId' => 1, 'fileName' => 'asd2.png', 'time' => 0, ), 4 => array ( 'id' => 3, 'post' => 'ouch', 'userId' => 2, 'fileName' => NULL, 'time' => NULL, ), ); foreach ($postArray as $post) { $fixed_part = array('id' => $post['id'], 'post' => $post['post'], 'userId' => $post['userId']); $key = serialize($fixed_part); if (!isset($out[$key])) $out[$key] = $fixed_part; $out[$key]['attachments'][] = array('fileName' => $post['fileName'], 'time' => $post['time']); } $out = array_values($out); echo json_encode($out, JSON_PRETTY_PRINT);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 28
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 28
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 19
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/aAa32
function name:  (null)
number of ops:  39
compiled vars:  !0 = $postArray, !1 = $post, !2 = $fixed_part, !3 = $key, !4 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1      > FE_RESET_R                                       $6      !0, ->28
          2    > > FE_FETCH_R                                               $6, !1, ->28
    5     3    >   FETCH_DIM_R                                      ~7      !1, 'id'
          4        INIT_ARRAY                                       ~8      ~7, 'id'
          5        FETCH_DIM_R                                      ~9      !1, 'post'
          6        ADD_ARRAY_ELEMENT                                ~8      ~9, 'post'
          7        FETCH_DIM_R                                      ~10     !1, 'userId'
          8        ADD_ARRAY_ELEMENT                                ~8      ~10, 'userId'
          9        ASSIGN                                                   !2, ~8
    6    10        INIT_FCALL                                               'serialize'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $12     
         13        ASSIGN                                                   !3, $12
    7    14        ISSET_ISEMPTY_DIM_OBJ                         0  ~14     !4, !3
         15        BOOL_NOT                                         ~15     ~14
         16      > JMPZ                                                     ~15, ->19
         17    >   ASSIGN_DIM                                               !4, !3
         18        OP_DATA                                                  !2
    8    19    >   FETCH_DIM_R                                      ~20     !1, 'fileName'
         20        INIT_ARRAY                                       ~21     ~20, 'fileName'
         21        FETCH_DIM_R                                      ~22     !1, 'time'
         22        ADD_ARRAY_ELEMENT                                ~21     ~22, 'time'
         23        FETCH_DIM_W                                      $17     !4, !3
         24        FETCH_DIM_W                                      $18     $17, 'attachments'
         25        ASSIGN_DIM                                               $18
         26        OP_DATA                                                  ~21
    4    27      > JMP                                                      ->2
         28    >   FE_FREE                                                  $6
   10    29        INIT_FCALL                                               'array_values'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                         $23     
         32        ASSIGN                                                   !4, $23
   11    33        INIT_FCALL                                               'json_encode'
         34        SEND_VAR                                                 !4
         35        SEND_VAL                                                 128
         36        DO_ICALL                                         $25     
         37        ECHO                                                     $25
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.21 ms | 1017 KiB | 16 Q