vscode中文版插件
vscode运行php代码
1.插件安装
2.配置项
左上角文件——首选项——设置——输入php.validate.executablePath
{
"workbench.colorTheme": "Default Dark Modern",
"php.validate.executablePath": "E:/phpstudy/php.exe",
"php.debug.executablePath": "E:/phpstudy/php.exe",
"phpserver.phpConfigPath": "E:/phpstudy/php.ini",
"phpserver.phpPath": "E:/phpstudy/php.exe"
}
3.尝试运行
代码:
<?php
$data = '{
"hbt": "0",
"hbt2": "2",
"hbt3": "3"
}';
// 将JSON字符串转换为关联数组
$array = json_decode($data, true);
// 遍历数组并筛选出值不为0的对象
$result = array();
foreach ($array as $key => $value) {
if ($value != "0") {
$result[$key] = $value;
}
}
// 输出结果
foreach ($result as $key => $value) {
echo $key . ": " . $value . "\n";
}
这样代表运行成功