陣列常用的內建函數
<?php
$classmate = array("Alicia","Balo","Cindy");
if(in_array("Alicia",$classmate)) {
echo "Yes";
}else{
echo "No";
};
?>
輸出:
Yes
<?php
$classmate = array("Alicia","Balo","Cindy");
echo array_search("Alicia",$classmate) ;
?>
輸出:
0
<?php
$classmate = array("Alicia","Balo","Cindy");
shuffle($classmate);
echo print_r($classmate) ;
?>
輸出:
Array ( [0] => Cindy [1] => Balo [2] => Alicia )
<?php
$classmate = array("Balo","Cindy","Alicia");
sort($classmate);
echo print_r($classmate) ;
?>
輸出:
Array ( [0] => Alicia [1] => Balo [2] => Cindy )
常用的其他函數
➤time() :回傳目前伺服器所在的時間。
➤getdate():回傳目前伺服器所在的日期。
➤is_null() : 檢查變數是否為NULL。
➤is_bool() : 檢查變數是否為布林值。