Commonly used array operation functions in php (1/8)_PHP tutorial
WBOYOriginal
2016-07-13 17:13:05927browse
An array is a set of elements that share certain characteristics, including similarity and type.
Each element is distinguished by a special identifier, called a key, and each key has a value
1. Two ways to create an array:
1.1 Use array() function
$numbers = range (0, 10);
foreach ( $numbers as $num )
{
echo $num . ' ';
}
$letters = range ( 'a', 'z' );
foreach ( $letters as $letter )
{
echo $letter . ' ';
}
?>
output
0
1
2
3
4
5
6
7
8
9
10
a
c
d
e
f
g
h
i
j
k
l
m
o
q
r
t
u
v
w
x
y
z
2. Two ways to loop through array elements:
2.1 for loop
The code is as follows
Copy code
';
}
?>
output
1
3
5
7
9
1 2 3 4 5 6 7 8
http://www.bkjia.com/PHPjc/629237.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629237.htmlTechArticleAn array is a group of elements that have certain common characteristics, including similarity and type. Each element is distinguished by a special identifier, called a key, and each key has a value 1. Create a number...
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