php definition array instance php array definition method_PHP tutorial

WBOY
Release: 2016-07-13 10:35:00
Original
899 people have browsed it

<?<span php 

</span><span //</span><span 定义一个字符串数组</span>
<span $fruit</span> = <span array</span>(\"<span apple\",\"orange\");
//引用数组的值
</span><span $fruit</span><span [0];//代表的值是apple
</span><span $fruit</span><span [1];//代表的值是orange
//注意,数组的索引是从0开始的,学过c 和java 的人都知道呀。
// 脚本学堂 www.jbxue.com
//定义一个数值型的数组
</span><span $number</span><span  = array(1,2,3,4,5);//引用数组的值同上

//定义一个符合型的数组
</span><span $mix</span><span  = array(1,\"example\",\"hello\",2.5);//引用数组的值同上

//还可以用键值方式定义数组
</span><span $ex</span><span  = array(\"a\"=>\"水果\",\"b\"=>\"汽车\");
//可以这样去引用
</span><span $ex</span><span [\"a\"];//对应的值就是水果
</span><span $ex</span><span [\"b\"];//对应的值就是汽车
//也可以创建这样的键值符合型的数组
?></span>
Copy after login

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/747271.htmlTechArticle? = ("...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template