继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

php入门之数组(1)

大叔_fighting
关注TA
已关注
手记 81
粉丝 44
获赞 400

<?php
/
数组:在一个变量中,存储一个或多个值,每一个元素都有一个访问ID
foreach($arr as $key=>$value)
/
$arr = array('李海','PHP视频教程','29','1982-05-08');
//print_r($arr);
//echo "学员名是:".$arr[0]." 所学课程:".$arr[1]." 年龄:".$arr[2]." 生日:".$arr[3];
$arr1 = array("uname"=>"江梅","uclass"=>"DIV+CSS","age"=>"44","birth"=>"1958-08-11");
//print_r($arr1);
//echo "年龄:".$arr1['age']."出生日期:".$arr1['birth'];
$arr2 = array(array("uname"=>"李满","age"=>"15"),array("uname"=>"小海","age"=>"38"));
echo "<pre>";
//print_r($arr2);
//echo $arr2[1]["uname"];
$arr3["网站名称"]="后盾网";
$arr3["课程"]="php教程";
$arr3["课时"]="300课时";
//print_r($arr3);
$arr4[]="PHP课程";
$arr4[]="网站标准布局课程";
//print_r($arr4);
$arr5["PHP"]=array();
$arr5["PHP"]['cname']="php课程";
$arr5["PHP"]['ctime']="300课时";
$arr5["DIV"]=array();
$arr5["DIV"]['cname']="DIV+CSS课程";
$arr5["DIV"]['ctime']="100课时";
$arr5['HTML']="HTML基础知识如TABLE,IFRAME课程";
$arr5['JAVASCRIPT']="js知识,jqery课程";
//print_r($arr5);

/*
foreach($arr3 as $k=>$value){

if($k == "课程"){
echo $k. "<span style='color:#f00; border:solid 1px #ccc; padding:2px; width:200px;'>".$value."</span>";
}else{
echo $k.$value;
}

}
/
/

foreach($arr5 as $key => $value){
echo "<div style='border:solid 1px #582553;margin-bottom:6px;font-size:14px;'>";
if(is_array($value)){
echo $key.":
";
foreach($value as $k=>$v){
echo " <span style='font-size:12px;'>".$k."=>".$v."</span>";
}
}else{
echo $key."=>".$value;
}
echo "</div>";
}
/
/

foreach($arr5 as $key => $value){
echo "<div style='border:solid 1px #582553;margin-bottom:6px;font-size:14px;'>";
if(is_array($value)){
echo $key.":
";
echo "课程名:".$value['cname']." 课时:".$value['ctime'];

}else{
echo $key."=>".$value;
}
echo "</div>";
}
/
$db = new mysqli('localhost','root','123456','edu') or die('连接错误');
$db->query("set names gbk");
$sql ="select
from user";
$result = $db->query($sql);
echo "<table border=1>";
while($row = $result->fetch_assoc()){
echo "<tr>";
echo "<td>学员名:</td><td><b>{$row['uname']}</b></td><td>课程名:{$row['cname']}</td>";
echo "</tr>";
}
echo "</table>";

打开App,阅读手记
1人推荐
发表评论
随时随地看视频慕课网APP