数组:
array(6) {
[0]=>
array(11) {
["id"]=>
string(2) "76"
["topic_id"]=>
string(1) "2"
["title"]=>
string(48) "大社区的完善配套大社区的完善配套"
["kwords"]=>
string(0) ""
["description"]=>
string(48) "大社区的完善配套大社区的完善配套"
["content"]=>
string(55) "<p>大社区的完善配套大社区的完善配套</p>"
["pic"]=>
string(32) "./uploads/201411080511370202.png"
["author"]=>
string(6) "系统"
["uptime"]=>
string(19) "2014-11-08 17:25:37"
["is_show"]=>
string(1) "1"
["article_topic"]=>
array(4) {
["id"]=>
string(1) "2"
["name"]=>
string(12) "工程进度"
["parent_id"]=>
string(1) "0"
["is_show"]=>
string(1) "1"
}
}
[1]=>
array(11) {
["id"]=>
string(2) "75"
["topic_id"]=>
string(1) "2"
["title"]=>
string(48) "大社区的完善配套大社区的完善配套"
["kwords"]=>
string(0) ""
["description"]=>
string(48) "大社区的完善配套大社区的完善配套"
["content"]=>
string(55) "<p>大社区的完善配套大社区的完善配套</p>"
["pic"]=>
string(32) "./uploads/201411080511220202.png"
["author"]=>
string(6) "系统"
["uptime"]=>
string(19) "2014-11-08 17:25:22"
["is_show"]=>
string(1) "1"
["article_topic"]=>
array(4) {
["id"]=>
string(1) "2"
["name"]=>
string(12) "工程进度"
["parent_id"]=>
string(1) "0"
["is_show"]=>
string(1) "1"
}
}
.
.
.
}
//要把每个 ["uptime"]=>string(19) "2014-11-08 17:25:22" 里面的日期换成‘xxxx-xx-xx’格式
使用foreach ($array as &$arr){
$arr['uptime'] = date('Y-m-d', strtotime($arr['uptime']));
}本回答被提问者采纳
$arr[$key]['uptime'] = '替换时间格式';
}
foreach($a as $v)//循环取出$a里面的数组
{
$v['uptime']=substr($v['uptime'],0,10);//截取日期前10位,就是xxxx-xx-xx
//$v['uptime']=date('Y-m-d');//如果是取当前日期就是这个
}
foreach ($robot as &$v){
$v['uptime'] = date("y-m-d",strtotime($v['uptime']));
}