我有这个问题而且不知道如何解决它。
错误在此行:$data = (string) "'".$array->$key."'";
function console_array( $array = null ){
$jsArray = null;
foreach ($array as $key => $value) {
$data = null;
if (is_int($array->$key)){
$data = (int) $array->$key;
} else {
$data = (string) "'".$array->$key."'";
}
$jsArray.= "jsArray['$key'] = $data;";
}
echo "<script>var jsArray = new Array(); $jsArray window.console.dir(jsArray);</script>";
}
答案 0 :(得分:0)
将$array->$key
替换为$array[$key]