PHP array function definition and usage summary

Source: Internet
Author: User
Tags random shuffle scalar sorts
Array pointer operation: Moves the array pointer operation: Next () down Gets the value of the current element. Prev () will also get the value of the current element. End () moves to the last element cell to get the value of the last element reset () moves to the first cell to get the value of the first element. Returns False if the move is unsuccessful. Parameters are arrays that require manipulation, and are reference passes. Gets the information for the element that the pointer points to: key ();//Gets the element that the current array pointer points to, and//obtains the element that the current array pointer points to only get the data do not move the pointer there is a mixed operation: that can get the current pointer element information (key value) can also move the pointer. each (); Gets the information of the current element (key and value information), one. Moving pointers: We can sometimes use each of the features to reach

1. Recommended PHP array pointer effects

Summary: Manipulating an array pointer: Moving an array pointer: Next ()   down   also gets the value of the current element. Prev ()   Gets the value of the current element at the same time. End ()   move to the last element cell   get the value of the last element reset ()   move to the first cell   get the value of the first element. Returns False if the move is unsuccessful. Parameters are arrays that require manipulation, and are reference passes.    won ...

2. Recommended 10 articles for PHP arrays

Introduction: The Interception of PHP arrays, the partial and replacement parts of the array in this article will introduce the interception of arrays (array_slice), equal (Array_chunk) and replacement (Array_splice) and Array_slice and array_splice the difference! In the previous three articles, "How do I sort php arrays?" "PHP array random Shuffle and reverse order" and "reverse order of PHP arrays", we introduced the array of sorts, including the ascending of the array, descending and disorderly order and reverse order, I believe that the logarithm ...

3. Definition and usage of PHP array function Array_push ()

Summary: the Array_push () function in PHP is to add one or more elements (into the stack) to the end of the array of the first parameter, and then return the length of the new array. This article introduces the syntax of the PHP Array_push () function and some small examples to take a look at it.

4. Array_diff and other methods to implement the difference between PHP array traversal

Introduction: give you two arrays with 5,000 elements, calculate their difference, and plainly, that is, using PHP and you think the best algorithm to implement Array_diff algorithm. The first time I received this topic, I found it very simple, so according to previous experience wrote one:

5. How are the PHP arrays merged?

Introduction: First of all, let's introduce what is Array_merge (): It is to combine an array unit or multiple array cells, a value in an array, which is appended to the previous array, and returns an array as the result.

6. Capturing, dividing, and replacing parts of an array of PHP arrays

Introduction: In this article we will describe the interception of arrays (Array_slice), Array_chunk and substitution (Array_splice), and the difference between Array_slice and Array_splice!

7. PHP array random sequence and reverse sequence of examples of detailed

Introduction: In the first two articles, "How to sort the PHP array" and "reverse of the PHP array" described in two sets of functions, a set of ascending, a set of reverse (descending), today we have this article with you about the random sequence and reverse order of the array!

8. Reverse Order of PHP arrays

Introduction: In an article "How to sort PHP arrays" we introduced the sort, asort, and Ksort, which are sorted in ascending order of arrays, so if you want to implement the reverse of the array? Here's another set of functions we're going to say: Rsort, Arsort, Krsort below we'll introduce this set of functions!

9. How do I sort the PHP array?

Introduction: We in the daily PHP array development, many projects are not necessary to sort the array, then there are several methods of ordering in PHP arrays, namely: Asort () function and Ksort () function, today one by one today to introduce you!

Example of using a foreach traversal array in a PHP array (figure)

Summary: When we use foreach to iterate through an array, we often make mistakes due to unclear concepts, and briefly describe common foreach operations.

11. How to delete duplicate elements in a PHP array

Summary: the Array_unique () function, which sorts the values of an array element as a string, and then retains only the first key name for each value, ignoring all subsequent key names, or deleting duplicate elements in the array.

12. How to remove headers, tails, arbitrary elements from the PHP array

Introduction: In a previous article we introduced how to add elements to the headers and tails in a PHP array since there are elements to add, then there is the deletion element, and today this article details how to delete the head and tail elements in the array, as well as any array elements.

13. How to add elements to headers and tails in a PHP array

Summary: the Array_push () function treats an array as a stack, pushes the incoming variable into the end of the array, and the length of the array increases as the number of variables in the stack increases, returning the total number of new cells in the array.

PHP arrays and strings convert each other

Introduction: String and array conversion is often used during program development, PHP mainly uses the explode () function and the implode () function, which we explain in detail below.

Type of PHP array-numeric index array

Introduction: The PHP numeric index array generally represents the position of the array element in the array, it is composed of numbers, the subscript starting from 0, the index array default index value is starting from the number 0, do not need to specifically specify, PHP automatically assigns an integer value to the index array's key name, and then from this value to start the automatic increment, of course, You can also specify to start saving data from a location.

The type of PHP array-associative array

Summary: It contains scalar data, which can be selected individually by index values, and the array is not a nonnegative integer but an arbitrary scalar. These scalars are called keys and can be used later to retrieve the values in the array.

Type of PHP array-multidimensional array

Summary: We need to understand that an array is not necessarily a simple list of subscripts and values, and in fact, each element in an 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 operational whole.

PHP Arrays Insert elements anywhere, deleting instance details for a specific element

Introduction: The following small series for everyone to bring an array anywhere insert element, delete the instance of a particular element. Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.

PHP Array Pointers

Introduction: This article introduces PHP array pointers

PHP array functions (merge, Split, append, find, delete, etc.)

Summary: the Array_merge () function merges an array together to return an array of unions. The resulting array starts with the first input array parameter, forcing it sequentially in the order in which the array parameters appear later. The form is:

PHP Array function sequence Array_unique ()-Removes duplicate element values from the array

Summary: the Array_unique () function shifts the duplicate values in the array and returns the result arrays. When the values of several array elements are equal, only the first element is preserved, and the other elements are deleted.

The implementation of PHP array de-weight faster

Introduction: Using PHP's Array_unique () function allows you to pass an array, and then remove the duplicate values, return a unique value of the array, through this article to introduce the PHP array to the more rapid implementation of the method, the need for friends to refer to this article

PHP Array Functions Knowledge Summary

Introduction: What is an array? An array is a place that is named to store a series of values. This article summarizes the basic knowledge points of PHP array functions, and interested partners can refer to

PHP Array function sequence Array_splice ()-Inserts an element anywhere in the array

Summary: the Array_splice () function is similar to the Array_slice () function, selecting a series of elements in an array, but not returning them, but deleting them and replacing them with other values.

"Related question and answer recommendation":

What is the difference between $arr [0] and $arr[' 0 ']?

An issue with the PHP array to the string

PHP array using Php_encode and then using Json.parse to convert to JS object will be error (before the array has a value is a JSON string)

PHP Array Conversion

How to write a PHP array to a file in a format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.