PHP code example of amostajo / php-json-array

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

    

amostajo / php-json-array example snippets


$array = new JSONArray();

$array[] = 'example';

$array['ID'] = 123;
$array['person'] = ['name' => 'John', 'lastname' => 'Doe'];

// To JSON
echo $array->toJson();

// To string (casts to JSON at the end)
echo (string)$array;

// Writes array as json string into filename.
$array->write($filename);

// Reads from filename.
$array->read($filename);

// Use loaded array
echo $array[$key];
bash
composer