本文的copyright归yuweixian4230@163.com 所有,使用GPL发布,可以自由拷贝,转载。但转载请保持文档的完整性,注明原作者及原链接,严禁用于任何商业用途。
作者:yuweixian4230@163.com
博客:yuweixian4230.blog.chinaunix.net
- <?php
-
$states = array("ohio","new york");
-
//数组头添加元素
-
array_unshift($states,"california","texas");
-
//array_push();数组尾添加元素
-
//array_shift();从数组头删除元素
-
//array_pop();从数组尾删除元素
-
$count = 0;
-
for($count = 0; $count < 4; $count++)
-
{
-
echo "$states[$count]
";
-
}
-
-
//in_array() 索引数组
-
echo "
";
-
$state = "ohio";
-
if(in_array($state,$states))
-
echo "find it
";
-
-
//array_key_exists() 关联数组键值
-
echo "
";
-
$state1["delaware"] = "december 7,1787";
-
$state1["ohio"] = "march 1,7895";
-
if(array_key_exists("ohio",$state1))
-
printf("find ohio, %s
",$state1["ohio"]);
-
-
//array_search()
-
//state2[ohio] = "march 1";
-
//array_search("march 1",$state2);
-
-
//array_keys() 数组键
-
$key = array_keys($state1);
-
print_r($key);
-
-
//array_values 全部值
-
echo "
";
-
print_r(array_values($state1));
-
?>
- california
-
texas
-
ohio
-
new york
-
-
find it
-
-
find ohio, march 1,7895
-
Array ( [0] => delaware [1] => ohio )
-
Array ( [0] => december 7,1787 [1] => march 1,7895 )
阅读(806) | 评论(0) | 转发(0) |