我正在尝试将制表符json标准化为另一种格式,但是在显示时发现了问题 我从旧表中获取了我需要的所有数据,但我想我的问题是将一个表放在另一个表下
这是我的标签json
Array
(
[totals] => Array
(
[errors] => 2
[warnings] => 0
[fixable] => 0
)
[files] => Array
(
[/home/ke/Test-Code/test/CODE.php] => Array
(
[errors] => 2
[warnings] => 0
[messages] => Array
(
[0] => Array
(
[message] => Missing file doc comment
[source] => PEAR.Commenting.FileComment.Missing
[severity] => 5
[type] => ERROR
[line] => 2
[column] => 1
[fixable] =>
)
[1] => Array
(
[message] => Expected "for (...) {\n"; found "for (...)\n{\n"
[source] => PEAR.ControlStructures.ControlSignature.Found
[severity] => 5
[type] => ERROR
[line] => 12
[column] => 1
[fixable] =>
)
)
)
)
)
应成为:
Array(/home/ke/Test-Code/test/CODE.php
Array
(
[RulesName] => PEAR.Commenting.FileComment.Missing
[RulesSaverity] => ERROR
[Errorline] => 2
)
Array
(
[RulesName] => PEAR.ControlStructures.ControlSignature.Found
[RulesSaverity] => ERROR
[Errorline] => 12
)
)
我尝试的问题是路径文件不是数组,而只是带有print-r的显示 我尝试将标签放在另一个标签或其他解决方案下
/home/ke/Test-Code/test/CODE.php
Array
(
[RulesName] => PEAR.Commenting.FileComment.Missing
[RulesSaverity] => ERROR
[Errorline] => 2
)
Array
(
[RulesName] => PEAR.ControlStructures.ControlSignature.Found
[RulesSaverity] => ERROR
[Errorline] => 12
)
这是我的代码
foreach ($var['files'] as $filePath => $file) {
print_r($filePath);
// print_r($arrayjson);
foreach ($file['messages'] as $message) {
$sourceRules = $message['source'];
$RulesSaverity = $message['type'];
$saverity = $RulesSaverity;
$ligne = $message['line'];
$errorline = $ligne;
//print_r($sourceRules);
$tableau_pour_json = ['RulesName' => $sourceRules, 'RulesSaverity' => $saverity, 'Errorline' => $errorline];
print_r($tableau_pour_json);
}
}