Skip to content

Instantly share code, notes, and snippets.

@ihzarizkyk
Created March 13, 2020 11:35
Show Gist options
  • Save ihzarizkyk/78bcc4e0ede85b07c9032848d6f7b4f5 to your computer and use it in GitHub Desktop.
Save ihzarizkyk/78bcc4e0ede85b07c9032848d6f7b4f5 to your computer and use it in GitHub Desktop.
JSON ENCODE & JSON DECODE
<?php
// JSON ENCODE
// FUNGSI UNTUK ENCODE SEBUAH ASSOSIATIF ARRAY KE FORMAT OBJEK JSON
$json1 = array("andi","budi","anton");
echo json_encode($json);
//HASIL
// ["andi","budi","anton"]
//JSON DECODE
// FUNGSI UNTUK DECODE DATA JSON KE PHP ASSOSIATIF ARRAY
$json2 = array("andi","budi","anton");
$encode = json_encode($json2);
$decode = json_decode($encode);
var_dump($decode);
//HASIL
//array(3) { [0]=> string(4) "andi" [1]=> string(4) "budi" [2]=> string(5) "anton" }
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment