我的代码:
$friends = [
['first_name' => "Cassidy", 'last_name' => "Nelson", 'age' => 21],
['first_name' => "Kyler", 'last_name' => "Besher", 'age' => 22],
['first_name' => "Caitlin", 'last_name' => "McGonigal", 'age' => 19],
['first_name' => "Matt", 'last_name' => "Miller", 'age' => 30],
['first_name' => "Skyler", 'last_name' =>"Stucky", 'age' => 22]
];
asort($friends);
foreach ($friends as 'first_name' => 'age' {
echo "$key = $val\n";
}
所以我对PHP是全新的,所以这可能是一个非常愚蠢的问题,但我想按照年龄顺序对朋友阵列中的朋友进行排序,同时还要显示他们的名字。我做错了什么?