Home>Article>Backend Development> Summary of php array function definition and usage
Operation of array pointer: Operation of moving array pointer: Next() downward and the value of the current element will be obtained at the same time. Prev() will get the value of the current element when going up. End() moves to the last element unit and gets the value of the last element. Reset() moves to the first unit and gets the value of the first element. If the move is unsuccessful, return false. The parameters are all arrays that need to be operated and are passed by reference. Get the information of the element pointed to by the pointer: Key();//Get the subscript of the element pointed to by the current array pointer Current();//Get the element pointed by the current array pointer. Only get the data without moving the pointer. There is also a mixed operation: that is You can get the information (key value) of the current pointer element and you can also move the pointer at the same time. Each(); obtains the information of the current element (key and value information), each. Moving pointer: We can sometimes use the characteristics of each to achieve
1.Recommended php array pointer effects
Introduction: Operation of array pointer: Operation of moving array pointer: Next() Down At the same time, the value of the current element will be obtained. Prev() Upward will also get the value of the current element. End() Move to the last element unit Get the value of the last element. Reset() Move to the first unit Get the value of the first element. If the move is unsuccessful, return false. The parameters are all arrays that need to be operated and are passed by reference. Get...
##2.10 recommended articles about php arrays
Introduction: PHP array interception, equal division and replacement of partial arrays. In this article, we will introduce the interception of arrays (array_slice), equal division (array_chunk) and replacement (array_splice) and The difference between array_slice and array_splice! In the previous three articles "How to sort PHP arrays?" "Random shuffle and reverse order of PHP arrays" and "Reverse order of PHP arrays", we introduced the sorting of arrays, including ascending and descending order of arrays. As well as disorder and reverse order, I believe everyone is familiar with arithmetic...
3.Definition and usage of php array function array_push()
Introduction: The array_push() function in PHP adds one or more elements (to the stack) to the end of the array of the first parameter, and then Returns the length of the new array. This article introduces the syntax of the php array_push() function and some small examples. Let’s take a look.
4.The difference between array_diff and other methods to implement PHP array traversal
Introduction: Give you two arrays with 5000 elements each, and calculate their difference. To put it bluntly, it means using PHP and the algorithm you think is the best to implement the array_diff algorithm. When I received this question for the first time, I found it to be very simple, so I wrote one based on my past experience:
##Introduction: First, let’s introduce what array_merge() is: it merges an array unit or Multiple array units are combined, the values in one array are appended to the previous array, and the resulting array is returned.
6.
Interception, equal division and replacement of partial arrays in PHP
Introduction: In this article, we will introduce the interception (array_slice), equal division (array_chunk) and replacement (array_splice) of the array as well as the difference between array_slice and array_splice!
7.Detailed explanation of examples of random shuffling and reverse ordering of PHP arrays
Introduction: In the first two articles "How to Sort PHP Arrays" and "Reverse Order of PHP Arrays", two sets of functions were introduced, one in ascending order and one in reverse order (descending order). Today we will introduce this article to you. Random shuffling and reverse ordering of arrays!
Introduction: In an article "How to Sort PHP Arrays" we introduced sort, asort and ksort. They all sort arrays in ascending order. So what if you want to implement the reverse order of the array? Here is another set of functions we are going to talk about: rsort, arsort, krsort. Below we will introduce this set of functions one by one!
Introduction: In our daily PHP array development, sorting of arrays is indispensable in many projects. So there are several sorting methods in PHP arrays, namely: asort() function and ksort() function. I will introduce them to you one by one today!
10.Detailed explanation of usage examples of foreach traversing arrays in php arrays (picture)
Introduction: When we use foreach to traverse an array, we often make mistakes due to unclear concepts. Here is a brief introduction to commonly used foreach operations.
11.How to remove duplicate elements from a PHP array
Introduction: The array_unique() function sorts the values of the array elements as strings, and then only retains the first key name for each value and ignores all subsequent key names, which is to delete duplicate elements in the array.
12.How to delete the head, tail, and any elements in a PHP array
Introduction: In a previous article, we introduced "How to add elements to the head and tail of a PHP array." Since there are elements to add, there are elements to delete. Today's article introduces it in detail How to delete head and tail elements in an array, as well as arbitrary array elements.
13.How to add elements to the head and tail of a PHP array
Introduction: The array_push() function treats the array as a stack and pushes the incoming variables into the end of the array. The length of the array will increase as the number of variables pushed onto the stack increases, and the array is returned. Total number of new units.
14.PHP array and string conversion
Introduction: The conversion of strings and arrays is often used in the process of program development. PHP mainly uses the explode() function and implode() function to implement it. We will explain it in detail below.
15.Type of PHP array - numeric index array
Introduction: PHP numeric index array generally represents the position of the array element in the array. It is composed of numbers. The subscript starts from 0. The default index value of the numeric index array starts from the number 0 and does not need to be specified. , PHP will automatically assign an integer value to the key name of the index array, and then automatically increment from this value. Of course, you can also specify a certain position to start saving data.
16.Type of PHP array - associative array
Introduction: It contains scalar data, which can be selected individually by index value. Unlike arrays, the index value of an associative array is not a non-negative integer but an arbitrary scalar. These scalars are called Keys and can later be used to retrieve values in the array.
17.Types of PHP arrays - multidimensional arrays
Introduction: We need to understand that an array is not necessarily a simple list of subscripts and values. In fact, each element in the array can also be another array.
18.What is a PHP array? What are the types of PHP arrays
Introduction: An array is a collection of data that organizes a series of data to form an operable whole.
Introduction: The following editor will bring you an example of inserting elements at any position in an array and deleting specific elements. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look
##Introduction: This article introduces PHP array pointers
21.PHP array functions (merge, split, append, search, delete, etc.)
Introduction: The array_merge() function merges arrays together and returns a combined array. The resulting array starts with the first input array parameter, and is added sequentially in the order in which subsequent array parameters appear. Its form is:
22.php array function sequence array_unique() - remove duplicate element values in the array
Introduction: The array_unique() function removes duplicate values from the array and returns the result array. When the values of several array elements are equal, only the first element is retained and the other elements are deleted.
23.The faster implementation of PHP array deduplication
Introduction: Using PHP's array_unique() function allows you to pass an array, then remove duplicate values and return an array with unique values. This article will introduce to you a faster implementation of PHP array deduplication. Friends who need it can refer to this article
24.PHP array function knowledge summary
Introduction: What is an array? An array is a named place used to store a series of values. This article mainly summarizes the most basic knowledge points of PHP array functions. Interested friends can refer to
25.php array function sequence array_splice() - Insert an element at any position in the array
##Introduction: array_splice() function is similar to array_slice() function, select A series of elements in the array, but does not return, but deletes them and replaces them with other values
[Related Q&A recommendations]:
$ What is the difference between arr[0] and $arr['0']?
A problem with converting a php array to a string
When using php_encode for a PHP array and then using JSON.parse to convert it into a js object, an error will be reported (before One of the values in the array is a json string)
How to write a PHP array into a file in a format
The above is the detailed content of Summary of php array function definition and usage. For more information, please follow other related articles on the PHP Chinese website!