<?php

    $data = file_get_contents ('./data.json');
    $json = json_decode($data, TRUE);
	
	$my_avatar = 1;
		
	foreach ($json as $key => $value) {
		
        switch ( $key ) {
            case 'prenom' :
                echo '&bull; Prénom: ' . $value . '<br />';
                break;
            case 'nom' : 
                echo '&bull; Nom: ' . $value . '<br />';
				break;
            case 'age' : 
                echo '&bull; Age: ' . $value . '<br />';
				break;
            case 'email' : 
                echo '&bull; Email: ' . $value . '<br />';
				break;
            case 'adresse' :
				echo '&bull; Adresse<ul>';
				
				foreach ($value as $ad_key => $ad_value) {
					switch ( $ad_key ) {
						case 'rue' : 
							echo '<li>Rue: ' . $ad_value . '</li>';
							break;
						case 'ville' : 
							echo '<li>Ville: ' . $ad_value . '</li>';
							break;
						case 'cp' : 
							echo '<li>CP: ' . $ad_value . '</li>';
							break;
						case 'pays' : 
							echo '<li>Pays: ' . $ad_value . '</li>';
							break;
					}
				}
				
				echo "</ul>";
                break;
				
            case 'photos_perso' : 
				echo '&bull; Photo perso :<br />';
				
				foreach ($value as $photo_key => $photo_value) {
					
					if ( $photo_key == $my_avatar ) echo "<img src='img/".$photo_value."' />";
					
					/*
					switch ( $photo_key ) {
						
						case '0' : 
							echo '<li>Photo n°1: ' . $photo_value . '</li>';
							break;
						case '1' : 
							echo '<li>Photo n°2: ' . $photo_value . '</li>';
							break;
						case '2' : 
							echo '<li>Photo n°3: ' . $photo_value . '</li>';
							break;
					}
					*/
				}
				
				//echo "</ul>";
				break;
        }

	}

?>
