PHP学习笔记——数组
2022/1/15 11:04:23
本文主要是介绍PHP学习笔记——数组,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
<?php // 在此之前的$addresses没有定义 echo $addresses[0]; // 无输出 echo $addresses; // 无输出 $addresses[0] = "100@100.com"; $addresses[1] = "111@111.com"; $addresses[2] = "222@222.com"; echo $addresses; $addresses = array("100@100.com","111@111.com","222@222.com"); echo $addresses; $price['apple'] = 1.00; $price['banana'] = 2.00; $price['oranger'] = 3.00; echo $price; $price = array( 'apple' => 1.00, 'banana' => 2.00, 'oranger' => 3.00 ); echo $price; $number = array(); /* 创建空数组 */ $color = array('Mike' => "black",'0' => "Brown",'1' => "Green"); /* 错误的代码,后面的键是从0开始的整数 */ $color = array('Mike' => "black","Brown","Green"); $family = array('Mike','Depp','Elliot'); $family[] = "Taylor"; /* $family[3]是"Taylor" */ $person = array('name' => "Niko"); $person[] = "S1mple"; /* $person[0] 是 "S1mple" */ $number = range(2, 5); /* $number = array(2, 3, 4, 5); */ $letters = range('a', 'z'); /* $letters 保存了字母表 */ $size = count($family); /* $size = 4 */ $scores = array(5, 10); $padded = array_pad($scores, 5, 0); /* $padded = array(5, 10, 0, 0, 0); */ $padded = array_pad($scores, -5, 1); /* $padded = array(1, 1, 1, 5, 10); */ $values = range('a','e'); list($m,$n,$o) = $values; /* $m = "a" , $n = "c" , $o = "e"; */ $order = array("Tom","Dick","Jack","Helen"); list($second,$third) = array_slice($order,1,2); /* $second = "Dick",$third = "Jack"; */ ?>
这篇关于PHP学习笔记——数组的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-11开源 PHP 商城项目 CRMEB 二次开发和部署教程
- 2024-11-09怎么使用php在kaufland平台刊登商品?-icode9专业技术文章分享
- 2024-11-05PHP的抽象类和接口是什么,有什么区别-icode9专业技术文章分享
- 2024-11-01开源 PHP 商城项目 CRMEB 安装和使用教程
- 2024-11-01用php和mysql写无限分类,有哪几种方法-icode9专业技术文章分享
- 2024-10-31php数据分表导出时部分数据无法导出什么原因-icode9专业技术文章分享
- 2024-10-30有经验的 PHP 开发者学习一门新的编程语言,有哪些推荐的有前景的语言-icode9专业技术文章分享
- 2024-10-21php 检测图片是否篡改过-icode9专业技术文章分享
- 2024-10-20fruitcake/php-cors 该怎么使用-icode9专业技术文章分享
- 2024-10-18PHP7.1可以使用哪个版本的swoole-icode9专业技术文章分享