Created
October 15, 2018 14:54
-
-
Save MkLHX/7a1b24d04c6d80029c80412886eb5f93 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$movies = [ | |
['title'=>'Indiana Jones et le Royaume du Crâne de Cristal', 'actors' => ['Harrison Ford', 'Cate Blanchett', 'Karen Allen']], | |
['title'=>'Indiana Jones et la Dernière Croisade', 'actors' => ['Harrison Ford', 'Sean Connery', 'Denholm Elliott']], | |
['title'=>'Indiana Jones et le Temple maudit', 'actors' => ['Harrison Ford', 'Kate Capshaw', 'Jonathan Ke Quan']] | |
]; | |
$result=""; | |
foreach ($movies as $movieKey => $movie) { | |
$result .= "Dans le film " . $movie['title'] . ", les principaux acteurs sont : " ; | |
foreach ($movie['actors'] as $actorKey => $actor) { | |
if($actorKey+1 == count($movie['actors'])){ | |
$result .= $actor.".".PHP_EOL; | |
}else{ | |
$result .= $actor . ","; | |
} | |
} | |
} | |
echo $result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment