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
Release: 2016-07-13 10:19:12
Original
945 people have browsed it

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: 1a0778c7e4968556f75eacc1966d6c02 3. Array sorting


Source: http://www.ido321.com/596.html

How to use arrays in php classes?

If you define private $a; as public $a, you can use $obj->a 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...
Related labels:
php
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