3v4l.org

run code in 300+ PHP versions simultaneously
<?php $m3u = '#EXTM3U #EXTINF:0 tvg-name="BBC" audio-track="eng" tvg-logo="http://mylogos.domain/BBC.png", BBC World http://server.name/stream/to/video2 #EXTINF:0 tvg-name="CNN" audio-track="rus", CNN International http://server.name/stream/to/video2 #EXTINF:0, Arirang http://server.name/stream/to/video3 #EXTINF:-1 tvg-id="http://www.arte.tv/" tvg-name="|ALLEMAGNE| ARTE ASTRA 19.2" tvg-logo="http://192.168.1.150/logotheque/arte_de.png" group-title="CULTURE ALLEMAGNE ASTRA 19.2",|ALLEMAGNE| ARTE ASTRA 19.2 http://192.168.1.150/1258'; $pattern = '~(*BSR_ANYCRLF) ^ \Q#EXTINF:\E (?<length> 0 | -1 | [1-9][0-9]* ) [ ]* (?<attributes> (?: [ ]* [\w-]+ =" [^"]* " \B )+ )? , [ ]* (?<title> .* \S ) [ ]* \R (?<url> .* \S ) ~xum'; preg_match_all($pattern, $m3u, $matches, PREG_SET_ORDER | PREG_UNMATCHED_AS_NULL); $results = []; $keys = array_flip(['length', 'attributes', 'title', 'url']); foreach($matches as $m) { if ( $m['attributes'] !== null ) { preg_match_all('~(?<name> [\w-]+ ) = " (?<value> [^"]* ) " ~x', $m['attributes'], $attr); $m['attributes'] = array_combine($attr['name'], $attr['value']); } $results[] = array_intersect_key($m, $keys); } print_r($results);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 39
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 39
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 32
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 32
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/oWblb
function name:  (null)
number of ops:  44
compiled vars:  !0 = $m3u, !1 = $pattern, !2 = $matches, !3 = $results, !4 = $keys, !5 = $m, !6 = $attr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%23EXTM3U%0A%0A%23EXTINF%3A0+tvg-name%3D%22BBC%22+audio-track%3D%22eng%22+tvg-logo%3D%22http%3A%2F%2Fmylogos.domain%2FBBC.png%22%2C+BBC+World%0Ahttp%3A%2F%2Fserver.name%2Fstream%2Fto%2Fvideo2%0A%23EXTINF%3A0+tvg-name%3D%22CNN%22+audio-track%3D%22rus%22%2C+CNN+International%0Ahttp%3A%2F%2Fserver.name%2Fstream%2Fto%2Fvideo2%0A%23EXTINF%3A0%2C+Arirang%0Ahttp%3A%2F%2Fserver.name%2Fstream%2Fto%2Fvideo3%0A%23EXTINF%3A-1+tvg-id%3D%22http%3A%2F%2Fwww.arte.tv%2F%22+tvg-name%3D%22%7CALLEMAGNE%7C+ARTE+ASTRA+19.2%22+tvg-logo%3D%22http%3A%2F%2F192.168.1.150%2Flogotheque%2Farte_de.png%22+group-title%3D%22CULTURE+ALLEMAGNE+ASTRA+19.2%22%2C%7CALLEMAGNE%7C+ARTE+ASTRA+19.2%0Ahttp%3A%2F%2F192.168.1.150%2F1258'
   14     1        ASSIGN                                                   !1, '%7E%28%2ABSR_ANYCRLF%29%0A%5E+%5CQ%23EXTINF%3A%5CE%0A%28%3F%3Clength%3E+0+%7C+-1+%7C+%5B1-9%5D%5B0-9%5D%2A+%29++++%5B+%5D%2A%0A%28%3F%3Cattributes%3E+%28%3F%3A+%5B+%5D%2A+%5B%5Cw-%5D%2B+%3D%22+%5B%5E%22%5D%2A+%22+%5CB+%29%2B+%29%3F++++%2C+%5B+%5D%2A%0A%28%3F%3Ctitle%3E+.%2A+%5CS+%29++++%5B+%5D%2A+%5CR%0A%28%3F%3Curl%3E+.%2A+%5CS+%29%0A%7Exum'
   22     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        SEND_VAL                                                 514
          7        DO_ICALL                                                 
   24     8        ASSIGN                                                   !3, <array>
   25     9        INIT_FCALL                                               'array_flip'
         10        SEND_VAL                                                 <array>
         11        DO_ICALL                                         $11     
         12        ASSIGN                                                   !4, $11
   27    13      > FE_RESET_R                                       $13     !2, ->39
         14    > > FE_FETCH_R                                               $13, !5, ->39
   28    15    >   FETCH_DIM_R                                      ~14     !5, 'attributes'
         16        TYPE_CHECK                                  1020          ~14
         17      > JMPZ                                                     ~15, ->32
   29    18    >   INIT_FCALL                                               'preg_match_all'
         19        SEND_VAL                                                 '%7E%28%3F%3Cname%3E+%5B%5Cw-%5D%2B+%29+%3D+%22+%28%3F%3Cvalue%3E+%5B%5E%22%5D%2A+%29+%22+%7Ex'
         20        FETCH_DIM_R                                      ~16     !5, 'attributes'
         21        SEND_VAL                                                 ~16
         22        SEND_REF                                                 !6
         23        DO_ICALL                                                 
   30    24        INIT_FCALL                                               'array_combine'
         25        FETCH_DIM_R                                      ~19     !6, 'name'
         26        SEND_VAL                                                 ~19
         27        FETCH_DIM_R                                      ~20     !6, 'value'
         28        SEND_VAL                                                 ~20
         29        DO_ICALL                                         $21     
         30        ASSIGN_DIM                                               !5, 'attributes'
         31        OP_DATA                                                  $21
   33    32    >   INIT_FCALL                                               'array_intersect_key'
         33        SEND_VAR                                                 !5
         34        SEND_VAR                                                 !4
         35        DO_ICALL                                         $23     
         36        ASSIGN_DIM                                               !3
         37        OP_DATA                                                  $23
   27    38      > JMP                                                      ->14
         39    >   FE_FREE                                                  $13
   36    40        INIT_FCALL                                               'print_r'
         41        SEND_VAR                                                 !3
         42        DO_ICALL                                                 
         43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.15 ms | 1019 KiB | 18 Q