Created
May 19, 2020 04:42
-
-
Save rwaddin/a3b5be8c13d2f98580ab7332772494cc to your computer and use it in GitHub Desktop.
Create file json use php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Data 1 | |
$data [] = array( | |
'no' => 1, | |
'nama' => 'Rudi', | |
'alamat' => 'Nganjuk' | |
); | |
// Data 2 | |
$data [] = array( | |
'no' => 2, | |
'nama' => 'Indah', | |
'alamat' => 'Madiun' | |
); | |
// Mengencode data menjadi json | |
$jsonfile = json_encode($data, JSON_PRETTY_PRINT); | |
// Menyimpan data ke dalam anggota.json | |
file_put_contents('anggota.json', $jsonfile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment