使用其中一列作为数组键获取的数组 - 获取错误消息“unexpected T_DOUBLE_ARROW”

时间:2013-04-17 19:05:43

标签: php arrays key

我正在尝试使用其中一个作为数组键提取的列创建数组,但我收到错误消息unexpected T_DOUBLE_ARROW

$students = array();
foreach ($rows as $row) { 
    $students[$row['first_name']] => $row['last_name'];
}

2 个答案:

答案 0 :(得分:1)

=>应替换为=

$students[$row['first_name']] = $row['last_name'];

答案 1 :(得分:0)

$students = array();
foreach ($rows as $row) { 
    $students=array($row['first_name'] => $row['last_name']);
}