3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'Some Text', 'Some Other Text (+£14.20)', 'Foo', 'Text Text (+£26.88)', 'Another One (+£68.04)', ]; $result = []; foreach ($array as $v) { $a = preg_split('/ \(\+£([^)]+)\)/', $v, 2, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); $result[$a[0]] = (float) ($a[1] ?? 0); } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/hI9ce
function name:  (null)
number of ops:  24
compiled vars:  !0 = $array, !1 = $result, !2 = $v, !3 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   12     2      > FE_RESET_R                                       $6      !0, ->19
          3    > > FE_FETCH_R                                               $6, !2, ->19
   13     4    >   INIT_FCALL                                               'preg_split'
          5        SEND_VAL                                                 '%2F+%5C%28%5C%2B%C2%A3%28%5B%5E%29%5D%2B%29%5C%29%2F'
          6        SEND_VAR                                                 !2
          7        SEND_VAL                                                 2
          8        SEND_VAL                                                 3
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !3, $7
   14    11        FETCH_DIM_R                                      ~9      !3, 0
         12        FETCH_DIM_IS                                     ~11     !3, 1
         13        COALESCE                                         ~12     ~11
         14        QM_ASSIGN                                        ~12     0
         15        CAST                                          5  ~13     ~12
         16        ASSIGN_DIM                                               !1, ~9
         17        OP_DATA                                                  ~13
   12    18      > JMP                                                      ->3
         19    >   FE_FREE                                                  $6
   16    20        INIT_FCALL                                               'var_export'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.81 ms | 1001 KiB | 15 Q