将字符串转换为数组

Chv*_*off 1 php

我有一个字符串 - 类似于

$string = 'key1=value1, key2=value2, key3=value3';
Run Code Online (Sandbox Code Playgroud)

如何从给定的字符串中获取如下的数组?

$array = array(
    'key1' => 'value1',
    'key2' => 'value2',
    'key3' => 'value3',
);
Run Code Online (Sandbox Code Playgroud)

You*_*nse 8

parse_str(str_replace(", ","&",$string),$array);
Run Code Online (Sandbox Code Playgroud)