Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有一些问题,下面的代码将最后一个 pr_name 分配给所有键。
$arr = array(); while($row = mysql_fetch_array($results)) { $keys[] = $row['pr_code']; $items = array_fill_keys($keys, $row['pr_name']); }
简单地说:
$items = array(); while($row = mysql_fetch_array($results)) { $items[$row['pr_code']] = $row['pr_name']; }