photoshop learning forum php learning array declaration
Copy code The code is as follows:
/*
* 1. Overview of arrays
* 1. The essence of arrays: manage and operate a set of variables, batch processing
* 2. Arrays Composite type (can store multiple)
* 3. Arrays can store data of any length and any type of data
* 4. Arrays can complete the functions of other language data structures (linked lists, queues, stacks, sets Class)
*
*
*
* 2. Classification of arrays
* There are multiple units in the array, (units are called elements)
* Each element (subscript [key] and value)
* Single access element Sometimes, elements are accessed through subscripts (keys)
* 1. One-dimensional array, two-dimensional array, three-dimensional array. . . Multidimensional array
* (an array of arrays means that other arrays are stored in the array)
* 2. There are two types of arrays in PHP
* Index array: the subscript is the index of a sequential integer
* Associative array: it is the subscript It is a string as an index
*
* There are only two subscripts (integer, string)
*
*
* 3. Multiple declaration methods of arrays
*
* 1. Directly assign a value to the array element declaration
* If the index If the subscript is not given, the sequential index will start from 0
* If the index subscript is given, the next one will be incremented by 1 from the largest
* If the previous subscript appears later, if it is an assignment, it will be the previous element Reassignment
* When mixed declaration, index and association do not affect each other (does not affect the declaration of index subscript)
*
* 2. Use the array() function to declare
* The default is an index array
* If specified for an associative array and an index array Subscript, use key => value
* Use " , " to split
* between multiple members 3. Use other function declarations
*
*
*
*
*/
//Index array
$user[ 0]=1;//User serial number
$user[1]="zhangsan";//User name
$user[2]=10;//Age
$user[3]="nan";//Gender
echo '
'; <br>print_r($user); <br>echo '';
//Associative array
$user["id"]=1;
$user["name"] ="zhangsan";
$user["age"]=10;
$user["sex"];
$user["age"]=90;//Assignment
echo $user["name"];/ /Output
//Use array() to declare an array
$user=array(1,"zhangsan",10,"nan");
//Use array() to declare an associative array
$user=array("id"= >1,"name"=>"zhangsan","age"=>10,"sex"=>"nan");
//Declare a multi-dimensional array (multiple records) to save in a table Multiple user information records
$user=array(
//Use $user[0] to call this line, such as calling the name in this record, $user[0][1]
array(1,"zhangsan" ,10,"nan"),
//Use $user[1] to call this line, for example, call the name in this record, $user[1][1]
array(2,"lisi",20," nv")
);
//Array saves multiple tables, each table has multiple records
$info=array(
"user"=>array(
array(1,"zhangsan",10,"nan "),
array(2,"lisi",20,"nv")
),
"score"=>array(
array(1,90,80,70),
array(2,60,40 ,70)
)
);
echo $info["score"][1][1];//Output 60,
?>
The above introduces the array declaration of photoshop learning forum and php learning, including the content of photoshop learning forum. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.
