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 ) */

preferences:
35.01 ms | 408 KiB | 5 Q