3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'title:hello;desc:message|title:lorem;desc:ipsum;ids:1,2,3'; $result = []; foreach (explode('|', $string) as $setString) { $set = []; foreach (explode(';', $setString) as $rowString) { [$key, $value] = explode(':', $rowString); $set[$key] = str_contains($value, ',') ? explode(',', $value) : $value; } $result[] = $set; } var_export($result); /* Array ( [0] => Array ( [title] => hello [desc] => message ) [1] => Array ( [title] => lorem [desc] => ipsum [ids] => Array ( [0] => 1 [1] => 2 [2] => 3 ) ) )*/
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 43
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 43
Branch analysis from position: 8
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 = 29, Position 2 = 35
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 39
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
filename:       /in/ihvn0
function name:  (null)
number of ops:  48
compiled vars:  !0 = $string, !1 = $result, !2 = $setString, !3 = $set, !4 = $rowString, !5 = $key, !6 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'title%3Ahello%3Bdesc%3Amessage%7Ctitle%3Alorem%3Bdesc%3Aipsum%3Bids%3A1%2C2%2C3'
    5     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%7C'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $9      
          6      > FE_RESET_R                                       $10     $9, ->43
          7    > > FE_FETCH_R                                               $10, !2, ->43
    7     8    >   ASSIGN                                                   !3, <array>
    8     9        INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '%3B'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $12     
         13      > FE_RESET_R                                       $13     $12, ->39
         14    > > FE_FETCH_R                                               $13, !4, ->39
    9    15    >   INIT_FCALL                                               'explode'
         16        SEND_VAL                                                 '%3A'
         17        SEND_VAR                                                 !4
         18        DO_ICALL                                         $14     
         19        FETCH_LIST_R                                     $15     $14, 0
         20        ASSIGN                                                   !5, $15
         21        FETCH_LIST_R                                     $17     $14, 1
         22        ASSIGN                                                   !6, $17
         23        FREE                                                     $14
   10    24        INIT_FCALL                                               'str_contains'
         25        SEND_VAR                                                 !6
         26        SEND_VAL                                                 '%2C'
         27        DO_ICALL                                         $20     
         28      > JMPZ                                                     $20, ->35
         29    >   INIT_FCALL                                               'explode'
         30        SEND_VAL                                                 '%2C'
         31        SEND_VAR                                                 !6
         32        DO_ICALL                                         $21     
         33        QM_ASSIGN                                        ~22     $21
         34      > JMP                                                      ->36
         35    >   QM_ASSIGN                                        ~22     !6
         36    >   ASSIGN_DIM                                               !3, !5
         37        OP_DATA                                                  ~22
    8    38      > JMP                                                      ->14
         39    >   FE_FREE                                                  $13
   12    40        ASSIGN_DIM                                               !1
         41        OP_DATA                                                  !3
    6    42      > JMP                                                      ->7
         43    >   FE_FREE                                                  $10
   14    44        INIT_FCALL                                               'var_export'
         45        SEND_VAR                                                 !1
         46        DO_ICALL                                                 
   37    47      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.15 ms | 1005 KiB | 16 Q