当前位置:网站首页>PHP basics uses arrays to save data
PHP basics uses arrays to save data
2022-07-29 10:52:00 【Go home at night】
Functional requirements
Define two arrays , The first array directly assigns values to the array ; The second array specifies the key name and value respectively , And the value of the array will be taken out according to the subscript of the array and the key name of the array .
The sample code
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> Use an array to save data </title>
</head>
<body>
<?php
// Assign values directly to the array
$arr1 = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
// Specify the key name and value for the array
$arr2 = array("animal" => "dog", "color" => "red");
// According to the array subscript “3”, get $arr1[2] The value of the element in the array “3”, Output :3
echo '$arr1[2] = '.$arr1[2]."<br>";
// According to the key name of the array “color”, get $arr2["color"] Elements of array “red”, Output :red
echo '$arr2["color"] = '.$arr2["color"]."<br>";
?>
</body>Running results

Knowledge description
Composite data types include arrays (array) And the object (object) Two kinds of
An array is a collection of data , It organizes a series of data , Form a whole operation . An array can contain a lot of data , Such as scalar data 、 Array 、 object 、 Resources and PHP Other syntax structures supported in .
PHP The data in is actually an ordered mapping . Mapping is a way of putting values( value ) Related to keys( Key name ) The type of . Array pass function array() Definition , Its value uses “key => value” How to set , Multiple values are separated by commas . Of course, you can also not use the key name , The default is 0、1、2、3、…….
边栏推荐
- 1. (map tools) detailed tutorial of acrgis desktop10.5 software installation
- HMS Core Discovery第16期回顾|与虎墩一起,玩转AI新“声”态
- 正则表达式匹配网址
- Create PHP message board system with kubernetes
- 浅谈安科瑞灭弧式智慧用电在养老机构的应用
- Adcode city code in Gaode map API
- Is error log monitoring enough? Don't try JVM monitoring of microservices
- What is "enterprise level" low code? Five abilities that must be possessed to become enterprise level low code
- Evolution of xxl-job architecture for distributed scheduling
- 若依集成minio实现分布式文件存储
猜你喜欢

How can agile development reduce cognitive bias in collaboration| Agile way

Summer 2022 software innovation laboratory training JDBC

Kunlunbase instruction manual (IV) real time synchronization of data from Oracle to kunlunbase

开源峰会抢先看 | 7月29日分论坛&活动议程速览

「PHP基础知识」使用数组保存数据

DoD 和 DoR,消减「认知偏差」的两大神器

数据可视化设计指南(信息图表篇)

Object storage

重磅 | 2022 开放原子全球开源峰会在北京开幕

牛客网刷题
随机推荐
架构实战营模块八作业
Drunken driving alarm system based on stm32
阿里P8爆出的这份大厂面试指南,看完工资暴涨30k!
QT工程基本构建
开源峰会抢先看 | 7 月 29 日分论坛 & 活动议程速览
2022cuda summer training camp Day2 practice
GPO:在 Start/Logon 中使用 PowerShell 脚本
Oracle advanced (XIV) explanation of escape characters
Factoextra: visualization of multivariate statistics
ES6-箭头函数this指向
Data visualization design guide (information chart)
正则表达式匹配网址
What is "enterprise level" low code? Five abilities that must be possessed to become enterprise level low code
JVM知识点详细整理(长文警告)
LeetCode_1049_最后一块石头的重量Ⅱ
深度强化学习应用实践技巧
If distributed file storage is realized according to integrated Minio
Oncopy and onpaste
R 语言 BRCA.mRNA数据集 分析
factoextra:多元统计的可视化