PHP code example of seffeng / json-helper

1. Go to this page and download the library: Download seffeng/json-helper 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/ */

    

seffeng / json-helper example snippets


/**
 * TestController.php
 * 示例
 */
namespace App\Http\Controllers;

use Seffeng\JsonHelper\Json;

class TestController extends Controller
{
    public function index()
    {
        $arr = [
            'a' => [
                'b' => [
                    'c' => 'ccc'
                ]
            ],
            'd' => [
                'b' => 'ccc',
                'e' => [
                    'f' => 'hhh'
                ]
            ]
        ];
        $json = Json::encode($arr);
        var_dump($json);
        print_r(Json::decode($json));
    }
}