Home > Backend Development > PHP Tutorial > Array Operation_PHP Tutorial

Array Operation_PHP Tutorial

WBOY
Release: 2016-07-13 17:26:31
Original
826 people have browsed it

PHP supports both scalar arrays and associative arrays. In fact, there is no difference between the two. You can create an array using the list() or array() functions, or you can explicitly set the value of each array element.
$a[0] = "abc";
$a[1] = "def";
$b["foo"] = 13;
You can also add to the array Numeric values ​​to create an array.
$a[] = "hello"; // $a[2] == "hello"
$a[] = "world"; // $a[3] == "world"
Arrays can be sorted through the functions asort(), arsort(), ksort(), rsort(), sort(), uasort(), usort(), and ksort(). Which function to use depends on your needs. It depends on the type of sorting you want.
You can use the cunt() function to count the number of elements in an array.
You can use the next() and prev() functions to traverse the array. Another common way to iterate over an array is to use the function each().

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531953.htmlTechArticlePHP supports both scalar arrays and associative arrays. In fact, there is no difference between the two. You can use the function list() or array() to create an array,...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template