3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '200AUD, 150USD, 80GBP, 1250000VND'; var_export( array_reduce( explode(',', $string), function ($result, $money) { sscanf($money, '%d%s', $amount, $currency); return $result + [$currency => $amount]; }, [] ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tjK7E
function name:  (null)
number of ops:  15
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '200AUD%2C+150USD%2C+80GBP%2C+1250000VND'
    5     1        INIT_FCALL                                               'var_export'
    6     2        INIT_FCALL                                               'array_reduce'
    7     3        INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '%2C'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
    8     8        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
   11     9        SEND_VAL                                                 ~3
   12    10        SEND_VAL                                                 <array>
    6    11        DO_ICALL                                         $4      
   12    12        SEND_VAR                                                 $4
    5    13        DO_ICALL                                                 
   14    14      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tjK7E
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $result, !1 = $money, !2 = $amount, !3 = $currency
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        INIT_FCALL                                               'sscanf'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 '%25d%25s'
          5        SEND_REF                                                 !2
          6        SEND_REF                                                 !3
          7        DO_ICALL                                                 
   10     8        INIT_ARRAY                                       ~5      !2, !3
          9        ADD                                              ~6      !0, ~5
         10      > RETURN                                                   ~6
   11    11*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.79 ms | 1014 KiB | 17 Q