Skip to content

Instantly share code, notes, and snippets.

@rwaddin
Created May 19, 2020 04:43
Show Gist options
  • Save rwaddin/528436a046d322d6aafc11efd3cdbb55 to your computer and use it in GitHub Desktop.
Save rwaddin/528436a046d322d6aafc11efd3cdbb55 to your computer and use it in GitHub Desktop.
Read a file json with php
<?php
// File json yang akan dibaca (full path file)
$file = "anggota.json";
// Mendapatkan file json
$anggota = file_get_contents($file);
// Mendecode anggota.json
$data = json_decode($anggota, true);
// Membaca data array menggunakan foreach
foreach ($data as $d) {
echo $d['no']. "<br>";
echo $d['nama']. "<br>";
echo $d['alamat']. "<br>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment