1.
$arr = array();
foreach ($re as $k=>$v){
$arr[] = $v[‘updatetime‘];
}
$arr的返回结果为:
Array ( [0] => 2014-09 [1] => 2015-04 [2] => 2015-09 )
$arr = array();
foreach ($re as $k=>$v){
$arr[$k] = $v[‘updatetime‘];
}
$arr的返回结果为:
Array ( [] => 2015-09 )从上面可以看出,新空数组,循环赋值时下标不能轻易也赋值,容易发生上面的错误!!!
时间: 2024-10-12 16:48:49