3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parse_value_string($string) { preg_match_all('/([a-z_]+):\s+(.*),/', $string, $matches); return array_combine($matches[1], array_map(function($val) { return trim($val, '"'); }, $matches[2])); } $test = '{ refresh_token: "xxxx", access_token: "xxxx", expires_in: 21600, }'; $values = parse_value_string($test); print_r($values); /* Array ( [refresh_token] => xxxx [access_token] => xxxx [expires_in] => 21600 ) */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PSf7d
function name:  (null)
number of ops:  9
compiled vars:  !0 = $test, !1 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, '%7B%0A++++refresh_token%3A+%22xxxx%22%2C%0A%0A++++access_token%3A+%22xxxx%22%2C%0A%0A++++expires_in%3A+21600%2C%0A%7D'
   19     1        INIT_FCALL                                               'parse_value_string'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   21     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
   29     8      > RETURN                                                   1

Function parse_value_string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PSf7d
function name:  parse_value_string
number of ops:  19
compiled vars:  !0 = $string, !1 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%28%5Ba-z_%5D%2B%29%3A%5Cs%2B%28.%2A%29%2C%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
    6     6        INIT_FCALL                                               'array_combine'
          7        FETCH_DIM_R                                      ~3      !1, 1
          8        SEND_VAL                                                 ~3
          9        INIT_FCALL                                               'array_map'
         10        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
    8    11        SEND_VAL                                                 ~4
         12        FETCH_DIM_R                                      ~5      !1, 2
         13        SEND_VAL                                                 ~5
    6    14        DO_ICALL                                         $6      
    8    15        SEND_VAR                                                 $6
    6    16        DO_ICALL                                         $7      
    8    17      > RETURN                                                   $7
    9    18*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PSf7d
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'trim'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%22'
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
    8     6*     > RETURN                                                   null

End of Dynamic Function 0

End of function parse_value_string

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.65 ms | 1471 KiB | 19 Q