这可以正常工作:
$datadump = '"Waived":"Waived", "Until":" until", "HeaderBanInfo":"Ban Info", "StatusLabel":"Current Status:", "StatusBanned":"BANNED", "StatusWarned":"WARNED", "StatusSuspended":"SUSPENDED", "StatusActive":"ACTIVE"';
$pattern = '/\"([a-zA-Z\s]*?)\":/si';
preg_match_all($pattern, $datadump, $output);
$names = $output[1];
echo $names[2]; /* this is a simple test */
编辑(仅适用于字母数字名称)
$datadump = '"a0":"Waived", "Until":" until", "HeaderBanInfo":"Ban Info", "StatusLabel":"Current Status:", "StatusBanned":"BANNED", "StatusWarned":"WARNED", "StatusSuspended":"SUSPENDED", "StatusActive":"ACTIVE"';
$pattern = '/\"([a-zA-Z0-9]*?)\":/si';
preg_match_all($pattern, $datadump, $output);
$names = $output[1];
for($i=0; $i<sizeof($names); $i++)
echo $names[$i] . "\n";
EDIT2(它允许名称和冒号之间有空格)
$datadump = '"a0" : "Waived", "Until":" until", "HeaderBanInfo":"Ban Info", "StatusLabel":"Current Status:", "StatusBanned":"BANNED", "StatusWarned":"WARNED", "StatusSuspended":"SUSPENDED", "StatusActive":"ACTIVE"';
$pattern = '/\"([a-zA-Z0-9]*?)\"[\s]*:/';
preg_match_all($pattern, $datadump, $output);
$names = $output[1];
for($i=0; $i<sizeof($names); $i++)
echo $names[$i] . "\n";