重新學習一下php的相關函數定義等內容,學習全部,加深印象,字母從a-z
首先學習php數組,array,數組定義,數組的初始化
看例子學習數組
例子1:有索引的數組
<?php
$forasp = array(size=>'forasp',domain=>'cn',name=>'');
//或者
print_r($forasp);
?>
輸出結果
array
(
[size] => forasp
[domain] => cn
[name] =>
)
例子2 無索引數組
<?php
$forasp = array(cn,2,3,4);
print_r($forasp);
?>
輸出結果:
array
(
[0] => cn
[1] => 2
[2] => 3
[3] => 4
)
例子3 二級數組以及多級數組
<?php
$forasp = array(class1=>一級數組內容,class2=>array(content=>二級數組內容));
print_r($forasp);
?>
輸出結果
array
(
[class1] => 一級數組內容
[class2] => array
(
[content] => 二級數組內容
)
)
例子4 動態(tài)添加數組內容
<?php
$forasp =array();
$forasp[]=anypoetry.com;//有索引內容
$forasp[] = 網站制作學習網;//無索引內容
print_r($forasp);
?>
輸出結果
array
(
[0] => anypoetry.com
[1] => 網站制作學習網
)
這就是php數組array的基本定義,下次繼續(xù)說php的相關的操作函數
更多信息請查看IT技術專欄