3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parse(array $lines): array { $result = []; foreach ($lines as $line) { $split = explode(': ', $line, 2); switch ($split[0]) { case 'file': unset($ref); $ref = [null, null, null]; $result[] = &$ref; break; case 'Artist': $ref[0] = $split[1]; break; case 'Album': $ref[1] = $split[1]; break; case 'Title': $ref[2] = $split[1]; break; } } return $result; } $array = [ 'MPD 0.23.5', 'file: Blondie/Parallel_Lines/12_Just_Go_Away.flac', 'Last-Modified: 2016-06-05T17:15:07Z', 'Format: 44100:16:2', 'Album: Parallel Lines', 'AlbumArtist: Blondie', 'Artist: Blondie', 'Composer: Debbie Harry', 'Date: 1978', 'Genre: Rock', 'Title: Just Go Away', 'Track: 12', 'Time: 214', 'duration: 213.800', 'Pos: 0', 'Id: 745', 'file: Blondie/Parallel_Lines/13_Once_I_Had_a_Love-aka_The_Disco_Song-1978_version-.flac', 'Last-Modified: 2016-06-05T17:15:01Z', 'Format: 44100:16:2', 'Album: Parallel Lines', 'AlbumArtist: Blondie', 'Artist: Blondie', 'Composer: Chris Stein; Debbie Harry', 'Date: 1978', 'Genre: Rock', 'Title: Once I Had a Love (aka The Disco Song) (1978 version)', 'Track: 13', 'Time: 198', 'duration: 198.000', 'Pos: 1', 'Id: 746', 'file: Blondie/Parallel_Lines/14_Bang_a_Gong-Get_It_On-live-.flac', 'Last-Modified: 2016-06-05T17:15:03Z', 'Format: 44100:16:2', 'Album: Parallel Lines', 'AlbumArtist: Blondie', 'Artist: Blondie', 'Composer: Marc Bolan', 'Date: 1978', 'Genre: Rock', 'Title: Bang a Gong (Get It On) (live)', 'Track: 14', 'Time: 330', 'duration: 330.293', 'Pos: 2', 'Id: 747', '' ]; var_export(parse($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EmgCJ
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ASSIGN                                                   !0, <array>
   78     1        INIT_FCALL                                               'var_export'
          2        INIT_FCALL                                               'parse'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function parse:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 40
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 40
Branch analysis from position: 4
6 jumps found. (Code = 188) Position 1 = 21, Position 2 = 26, Position 3 = 30, Position 4 = 34, Position 5 = 38, Position 6 = 12
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 38
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 26
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 30
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 34
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 34
Branch analysis from position: 30
Branch analysis from position: 26
Branch analysis from position: 21
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/EmgCJ
function name:  parse
number of ops:  45
compiled vars:  !0 = $lines, !1 = $result, !2 = $line, !3 = $split, !4 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    6     2      > FE_RESET_R                                       $6      !0, ->40
          3    > > FE_FETCH_R                                               $6, !2, ->40
    7     4    >   INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '%3A+'
          6        SEND_VAR                                                 !2
          7        SEND_VAL                                                 2
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !3, $7
    8    10        FETCH_DIM_R                                      ~9      !3, 0
         11      > SWITCH_STRING                                            ~9, [ 'file':->21, 'Artist':->26, 'Album':->30, 'Title':->34, ], ->38
    9    12    >   CASE                                                     ~9, 'file'
         13      > JMPNZ                                                    ~10, ->21
   14    14    >   CASE                                                     ~9, 'Artist'
         15      > JMPNZ                                                    ~10, ->26
   17    16    >   CASE                                                     ~9, 'Album'
         17      > JMPNZ                                                    ~10, ->30
   20    18    >   CASE                                                     ~9, 'Title'
         19      > JMPNZ                                                    ~10, ->34
         20    > > JMP                                                      ->38
   10    21    >   UNSET_CV                                                 !4
   11    22        ASSIGN                                                   !4, <array>
   12    23        FETCH_DIM_W                                      $12     !1
         24        ASSIGN_REF                                               $12, !4
   13    25      > JMP                                                      ->38
   15    26    >   FETCH_DIM_R                                      ~15     !3, 1
         27        ASSIGN_DIM                                               !4, 0
         28        OP_DATA                                                  ~15
   16    29      > JMP                                                      ->38
   18    30    >   FETCH_DIM_R                                      ~17     !3, 1
         31        ASSIGN_DIM                                               !4, 1
         32        OP_DATA                                                  ~17
   19    33      > JMP                                                      ->38
   21    34    >   FETCH_DIM_R                                      ~19     !3, 1
         35        ASSIGN_DIM                                               !4, 2
         36        OP_DATA                                                  ~19
   22    37      > JMP                                                      ->38
         38    >   FREE                                                     ~9
    6    39      > JMP                                                      ->3
         40    >   FE_FREE                                                  $6
   25    41        VERIFY_RETURN_TYPE                                       !1
         42      > RETURN                                                   !1
   26    43*       VERIFY_RETURN_TYPE                                       
         44*     > RETURN                                                   null

End of function parse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.91 ms | 1006 KiB | 16 Q