Home >Backend Development >PHP Tutorial >Summary of using php arrays, summary of php arrays_PHP tutorial

Summary of using php arrays, summary of php arrays_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:19:12948browse

Summary of using php arrays, summary of php arrays

In PHP, arrays are divided into two categories: index arrays and associative arrays. The two can be used alone or mixed.

1. One-dimensional array

The definition of a one-dimensional array is also very simple. There are two commonly used methods:

1.1 Direct assignment

1: 29c19bbcbb31a64f89da72211d94e174a directly.

$obj->a['key'] is the value you want to access.

Usage of php array

First of all, your way of writing is really different. Nowadays, PHP is more common in curly bracket writing

(1) For weak language PHP, it does not need to be initialized like a strict language. It is automatically initialized when used. . So after declaring the array, it can be used. And sometimes there is no need to declare it, such as writing $i = 1.25 directly; if an error is reported in a rigorous language, PHP can use it like this.
(2) The default index of the array starts from 0 and then increases by 1. count($arr) is the number of array elements. Assuming n is the number of elements in the current array, then $arr[n-1] is the element with the largest index. Adding $arr[n] is equivalent to adding an element at the end of the array. In fact, you can write $arr[] = $ss, and the effect is the same.
(3) Algorithm idea problem, which means that if a natural number can be divided by a smaller prime number than it, then it is not a prime number.
(4) There is nothing wrong with the program....

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/878338.htmlTechArticleSummary of using php arrays, summary of php arrays In PHP, arrays are divided into two categories: index arrays and associative arrays. The two can be used alone or mixed. 1. One-dimensional array One-dimensional array...
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