从列表构建数组

ahm*_*111 -4 php arrays

我怎么能建立一个以下字符串数组:

$scope = "calls:full,departments:full,employees:full,companies:full,stages:full,accounts:full,resources:full,products:full,reports:full";
Run Code Online (Sandbox Code Playgroud)

像这样代表它:

$scope = array(
    'calls' => full,
    'departments' => full,
    'employees' => full,
    .... and so on >>
);
Run Code Online (Sandbox Code Playgroud)

Nea*_*eal 5

$scope = "calls:full,departments:full,employees:full,companies:full,stages:full,accounts:full,resources:full,products:full,reports:full";
$parts = explode(',', $scope);
$arr = array();

foreach($parts as $val)   {
    list($key, $value) = explode(':', $val);
    $arr[$key] = $value; 
}
Run Code Online (Sandbox Code Playgroud)