这是我正在使用的通用解决方法:
http://codepad.viper-7.com/2tiPvN
$j=0;
$paper = array('copier' => "Copier and Multipurpose",
'inkjet' => "Injet Printer",
'laser' => "Laser Printer",
'photo' => "Photo Paper");
foreach ($paper as $index => $description)
{
echo "$j, $index: $description
";
$j++;
}
我想要数字标识符和关键字标识符。
同时,因为 foreach ($paper as $description) 给出了描述和
foreach ($paper as $index => $description)
给出索引,然后给出描述......,有没有办法只在 foreach 中获取索引,而不必为描述指定变量?