一开始打算用foreach来历遍,但是发现没有成功,oo不过关,没办法oo写······
研究后决定用for循环,演示代码如下:
$blog=array(
array(
"titledata"=>"titleMM",
"bodydata"=>"bodyMM"
),
array(
"titledata"=>"titleGG",
"bodydata"=>"bodyGG"
)
);
//出错
foreach($blog as $b)
{
$b['titledata']="BB";
$b['bodydata']="CC";
}
print_r($blog);
//正确
for($i=0;$i{
$blog[$i]['titledata']="title";
$blog[$i]['bodydata']="body";
}
?>
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn