I'm trying to normalize a tab json to another format but I found a problem when displaying I get all the data I need from the old table but I think my problem is to put a table under another table

this is my tab 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] => 
                                )

                        )

                )

        )

)

should become :

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
            )
)

that's what I tried the problem is that pathfile is not an array, just it's a display with print-r I try to put a tab under another tab or another solution

/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
            )

this is my code

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);
        }
    }

0 Answers