Skip to content

Instantly share code, notes, and snippets.

@MkLHX
Created October 15, 2018 14:54
Show Gist options
  • Save MkLHX/7a1b24d04c6d80029c80412886eb5f93 to your computer and use it in GitHub Desktop.
Save MkLHX/7a1b24d04c6d80029c80412886eb5f93 to your computer and use it in GitHub Desktop.
<?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