minte9
LearnRemember



Json

JSON (JavaScript Object Notation). It is the actual form that a JavaScript engine will map the object to in memory. PHP have native support for JSON.

Decode

Return the json representation of a value
 
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';

var_dump(json_decode($json)); // returns object
    // { "a"=> 1, "b"=>2, ... }

var_dump(json_decode($json, true)); // returns array
    // [ "a"=> 1, "b"=>2, ... ]

$json = '';
var_dump(json_decode($json));// NULL

Encode

Returns a JSON encoded string on success or FALSE on failure
     code
$arr = array('a' => 1, 'b' => 2, 'c' => 3);
echo json_encode($arr); // {"a":1,"b":2,"c":3}



  Last update: 424 days ago