Home >Backend Development >PHP Tutorial >PHP array index and key value operation skills example analysis, operation skills example analysis_PHP tutorial

PHP array index and key value operation skills example analysis, operation skills example analysis_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:48:49760browse

PHP array index and key value operation skills example analysis, operation skills example analysis

This article describes the PHP array index and key value operation skills with examples. Share it with everyone for your reference. The details are as follows:

<&#63;php 
$array = array("a", "b","c"); //定义数组 
$array[] = "Simon"; //增加一个新的数组元素 
print_r($array); //输出数组 
&#63;> 

<&#63;php 
$array = array("a", "b","c"); //定义数组 
$array[9] = "Simon"; //增加一个新的数组元素 
print_r($array); //输出数组 
&#63;> 

<&#63;php 
//创建一个简单的数组 
$array = array(0=>1, 1=>2, 2=>3, 3=>4, 6=>5); 
print_r($array); 
//现在把数组中键为2的值更新为100 
$array[2] = 100; 
print_r($array); 
//现在添加一个键 
$array["X"] = 50; 
print_r($array); 
//现在删除所有键,但保持数组本身的结构 
foreach($array as $i => $value)  
{ 
  unset($array[$i]); 
} 
print_r($array); 
//再添加一个键 
$array[] = 25; 
print_r($array); 
//使用array_values函数进行重新索引 
$array = array_values($array); 
$array[] = 13; 
print_r($array); 
&#63;>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1021086.htmlTechArticlePHP array index and key value operation skills example analysis, operation skills example analysis This article tells the example of php array index and key Value operation skills. Share it with everyone for your reference. The details are as follows:...
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