PHP MySQL内容保存到按id排序的数组


PHP MySQL content save to array sorted by id

$content_mysql = mysql_query("SELECT id, content FROM articles ");

我想保存内容从mysql到数组,如:

//在数据库表中:

id: 1含量:氧

id: 2含量:氢

//在php数组中

echo $array['1']; //It is says: oxigen
echo $array['2']; //It is says: hidrogen
$content_mysql = mysql_query("SELECT id, content FROM articles ");
$array = [];
while ($row = mysql_fetch_assoc($content_mysql)) {
    $array[(string)$row['id']] = $row['content'];
}