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

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

WBOY
WBOYOriginal
2016-05-16 20:22:261611browse

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

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

1、键、值。

数组的基本形式:

array( [key =>]
value
   , ...
)

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;>

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

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

Statement:
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