🏠 Accueil ◀️ TP Précédent TP Suivant ▶️

TP8B - Lecture et Affichage des Données JSON

Manipulation de fichiers JSON avec PHP

📊 Statistiques des données

Nombre d'étudiants: 10

Âge moyen: 20.2 ans

Formations: Licence Informatique, Licence Cybersécurité, DUT Informatique, Licence Cyber, CPGE MPSI, Médecine

👨‍🎓 Liste des étudiants

Kacper Kowalski

20 ans

Formation: Licence Informatique

Email: kacper@example.com

Matières: HTML, CSS, JavaScript, PHP, JSON

Inscrit le: 2024-01-15 10:30:00

Alice Martin

22 ans

Formation: Licence Cybersécurité

Email: alice@example.com

Matières: Réseaux, Sécurité, Python

Inscrit le: 2024-01-20 14:45:00

Bob Dubois

21 ans

Formation: DUT Informatique

Email: bob@example.com

Matières: Java, Base de données, Algorithmique

Inscrit le: 2024-01-25 09:15:00

Yasmine Assana

19 ans

Formation: Licence Cyber

Fatou

17 ans

Formation: Licence Cyber

Ayden

20 ans

Formation: CPGE MPSI

Lilia

18 ans

Formation: Médecine

Diawara

19 ans

Matières: Histoire

Lili

23 ans

Matières: maths

Youanne

23 ans

Matières: histoire, français

PHP
$fichier = 'etudiant.json';
if (file_exists($fichier)) {
    $json_data = file_get_contents($fichier);
    $etudiants = json_decode($json_data, true);
    
    foreach ($etudiants as $etudiant) {
        echo "Nom: " . $etudiant["nom"];
        echo "Âge: " . $etudiant["age"];
    }
}