PHP简单实现二维数组赋值与遍历功能示例
这篇文章主要介绍了PHP简单实现二维数组赋值与遍历功能,涉及php数组的简单赋值、遍历、运算、读取等操作使用技巧,需要的朋友可以参考下
本文实例讲述了PHP简单实现二维数组赋值与遍历功能。分享给大家供大家参考,具体如下:
示例1:
";
echo "图片:$tmp[pic]
";
echo "标题:$tmp[title]
";
echo "价格:$tmp[price]
";
echo "是否特价:$tmp[isOnSale]
";
echo "上架时间:" . date("Y-m-d H:i:s",$tmp['shelfTime']) . "
";
}
?>
运行结果:
示例2:
";
echo "用户名:$tmp[userName]
";
echo "密码:$tmp[passWord]
";
echo "邮箱:$tmp[email]
";
echo "手机:$tmp[tel]
";
echo "头像:$tmp[headScu]
";
if($tmp['sex'] == "M"){
echo "性别:男
";
}
if($tmp['sex'] == "F"){
echo "性别:女
";
}
echo "注册时间:" . date('Y-m-d H:i:s',$tmp['regTime']) . "
";
if($tmp['isOnline'] == 1){
echo "状态:在线
";
}
if($tmp['isOnline'] == 0){
echo "状态:不在线
";
}
}
?>