PHP code example of ninenight / json-printer

1. Go to this page and download the library: Download ninenight/json-printer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ninenight / json-printer example snippets


    $array = [
            'name' => '小红',
            'mobile' => '1888888888',
            'email' => [
                '[email protected]',
                '[email protected]',
                '[email protected]'
            ],
            'age' => '28',
            'sex' => '男',
            'address' => [
                '重庆市XXXXXXXX',
                [
                    '大渡口区XXXXXXX',
                    '渝北区CCCCCC',
                    '北碚区VVVVVVV'
                ],
            ],
        ];

        $newJson = (new Json($array))->jsonFormat();

        halt($newJson);

{
    "name":"小红",
    "mobile":"1888888888",
    "email":[
        "[email protected]",
        "[email protected]",
        "[email protected]"
    ],
    "age":"28",
    "sex":"男",
    "address":[
        "重庆市XXXXXXXX",
        [
            "大渡口区XXXXXXX",
            "渝北区CCCCCC",
            "北碚区VVVVVVV"
        ]
    ]
}