Skip to content

Instantly share code, notes, and snippets.

@rwaddin
Created May 19, 2020 04:42
Show Gist options
  • Save rwaddin/a3b5be8c13d2f98580ab7332772494cc to your computer and use it in GitHub Desktop.
Save rwaddin/a3b5be8c13d2f98580ab7332772494cc to your computer and use it in GitHub Desktop.
Create file json use php
<?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