Home > Backend Development > PHP Tutorial > php数组使用规则分析_php技巧

php数组使用规则分析_php技巧

WBOY
Release: 2016-05-16 20:22:26
Original
1650 people have browsed it

本文实例分析了php中数组的使用规则。分享给大家供大家参考。具体分析如下:

数组在php中处于灰常重要的地位。字符串、图片、数码、视频等值都以数组的形式存在,所以了解清楚数组的各种规则十分必要。

1、键、值。

数组的基本形式:

array( [key =>]
value
   , ...
)
Copy after login

key=>value,其中,key只能是两种,integer、string。而value可以是各种形式,除了数字,其它值都须用''或""把string括起来。下面示例说明了规则:

<&#63;php  
$a = array(-1=>2,
         -2=>3,
   '01'=>'99.jpg',
            8,
           'a',
     'b'=>TRUE,
         NULL,
            "",
      1.2=>0.5,
        );
  
     print_r($a);
&#63;>
Copy after login

输出结果:Array ( [-1] => 2 [-2] => 3 [01] => 99.jpg [0] => 8 [1] => 0.5  => 1 [2] => [3] => )

希望本文所述对大家的php程序设计有所帮助。

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