2013-03-06 39 views

回答

1

如果您需要將原始的字符串變換而PHP數組,你可以試試你需要更多的幫助

$str = '{28:1,29:0,30:1}'; 

$array = explode(',', trim($str, '{}')); 
$result = array(); 
foreach ($array as $x) 
{ 
    list($key, $value) = explode(':', $x, 2); 
    $result[$key] = $value; 
} 

echo "<pre>"; print_r($result);會給你

Array 
(
    [28] => 1 
    [29] => 0 
    [30] => 1 
) 

Example

+0

@DanielFain與問題? – peterm 2013-03-07 00:35:25

相關問題