php数组问题

来源:百度知道 编辑:UC知道 时间:2024/05/13 09:50:17
$result = $db->query("SELECT * FROM $mvm_gcomment_table WHERE guid='$product[uid]' AND approval_date>'0' ORDER BY uid DESC LIMIT 0,$mm_comment_nums");
while ($co_list = $db->fetch_array($result)) {
$co_list[title] = make_br(del_teg($co_list[comment_subject]));
$co_list[conter] = make_br(del_teg($co_list[comment_body]));
$co_list[name] = make_br(del_teg($co_list[comment_name]));
$co_list[date] = date("Y-m-d[h:i]", $co_list[register_date]);
$co_list[reply] = $co_list[comment_main];
$co_list[star] = $m_star_array[$co_list[comment_star]];
if($co_list[approval_date]>1){
$co_list[approval_date]= date("Y-m-d[h:i]",$co_list[approval_date]);
}else {
$co_list[approval_date]='';
}
$comment[] = $co_list;
}
我是php的初学者
1.比如co_list[comment_subject] ,comment_subject为什么没有用''逗号,
可以调用数据?

co_list[comment_subject],这个 comment_subject由于php不认识它,所以强制把它当字符串处理了,但同时也产生了一个警告,把php.ini的错误打开就能看见这个警告,不写引号的习惯不好。
title已经脱离数据表,它只是数组的key,和数据库字段没一点关系

1.因为comment_subject在PHP中并不是预先定义的常量或变量所以可以不用引号,最好是养成写引号的习惯
2.这个是通过几个函数对$co_list[comment_subject]进行调节,make_br这个看名字好象是加把什么符号替换成换行,del_teg这个看名字是替换html的代码