PROGRAMMING

  MINTE9
REMEMBERS




Last update:   25-04-2022

Javascript

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.

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

json_encode

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

Questions    
File open
        A B C D E F
🔔
1/1