Home > php教程 > php手册 > php数组键值用法实例分析,php数组实例分析

php数组键值用法实例分析,php数组实例分析

WBOY
Release: 2016-06-13 09:14:03
Original
1091 people have browsed it

php数组键值用法实例分析,php数组实例分析

本文实例讲述了php数组键值用法。分享给大家供大家参考。具体分析如下:

先看一个数组:

<&#63;php
$switching = array(
  10, // key = 0
  5  => 6,
  3  => 7,
  'a' => 4,
  11, // key = 6 (整个数组中整型键索引最大的值是5)
  '8' => 2, // key = 8 (字符串健'8'转换为8)
  '02' => 77, // key = '02'(注意不是2)
  0  => 12 
  /*前面值为10的键被赋予0,而后面重新定义了0键的值为12,
  从而覆盖了前面默认的0键值*/
 );
// empty array
$empty = array();
&#63;>
Copy after login

如果用print_r($switching)打印出来的话结果为:

Array ( [0] => 12 [5] => 6 [3] => 7 [a] => 4 [6] => 11 [8] => 2 [02] => 77 )

注意,两位数的02被排在后面。

希望本文所述对大家的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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template