[PHP網路編程從入門到精通]-3-10.php:單獨指定多維陣列每個元素賦值例子

[PHP網路編程從入門到精通]-3-10.php:單獨指定多維陣列每個元素賦值例子

[PHP網路編程從入門到精通]-3-10.php:單獨指定多維陣列每個元素賦值例子

 

 

 

<html>
<head>
<metahttp-equiv="Content-Type"content="text/html; charset=utf-8">
<title>3-10.php:單獨指定多維陣列每個元素賦值例子</title>
</head>
<body>
<?php
header("Content-Type:text/html; charset=utf-8");
//---------------------
$string[0][0]=0;//單獨給多維陣列每個元素賦值
$string[0][1]=1;
$string[0][2]=2;
$string[1][0]="string1";
$string[1][1]="string2";
$string[1][2]="string3";
$string[1][3]="string4";
$string[2][0]="你好!";
$string[2][1]="大家好,";
$string[2][2]="才��真的好";
for($i=0;$i<count($string);$i++)//通過迴圈讀取外層陣列內容
{
for($j=0;$j<count($string[$i]);$j++)//通過迴圈讀取內層陣列內容
{
echo$string[$i][$j];//顯示陣列元素
echo",";
}
echo"<br>";
}
?>
</body>
</html>



 



發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *