Home > Article > Backend Development > How to use arrays in php
This article mainly introduces the rules for using arrays in PHP. It analyzes the usage of arrays in PHP with examples. It has certain reference value. Friends in need can refer to it.
This article analyzes the usage of arrays in PHP with examples. rule.
The specific analysis is as follows:
Arrays occupy a very important position in PHP. Values such as strings, pictures, numbers, and videos all exist in the form of arrays, so it is necessary to understand the various rules of arrays.
1, key, value.
The basic form of an array:
array( [key =>] value , ... )
key=>value, where the key can only be two types, integer and string. The value can be in various forms. Except for numbers, other values must be enclosed in strings with '' or "". The following example illustrates the rules:
<?php $a = array(-1=>2, -2=>3, '01'=>'99.jpg', 8, 'a', 'b'=>TRUE, NULL, "", 1.2=>0.5, ); print_r($a); ?>
Output result: Array ( [-1] => 2 [-2] => 3 [01] => 99.jpg [0] => 8 [1] => 0.5 => 1 [2] => [3] => )
Summary: The above is the entire content of this article, I hope it can help Everyone’s learning helps.
Related recommendations:
PHP’s practical functions for implementing black and white lists
How does PHP list all databases in MySQL
How to add subtitles to video using php using ffmpeg
The above is the detailed content of How to use arrays in php. For more information, please follow other related articles on the PHP Chinese website!