This article mainly introduces how to learn PHP arrays [experience]. For more information, see
PHP has many array functions to facilitate array operations.
Definition:
Each object in the array contains two items: key and value. you can use the
A detailed explanation of the two-dimensional array sorting problem in php, two-dimensional array sorting. For details about the two-dimensional array sorting problem in php, two-dimensional array sorting in PHP, you can use the PHP built-in
You can use functions such as sort (), asort (), and arsort () to sort PHP one-dimensional arrays. However, you need to customize the sorting of PHP two-dimensional arrays. You can use functions such as sort (), asort (), and arsort () to sort PHP
Learn PHP's array summary "experience", PHP array Summary
PHP has a lot of functions for arrays, which makes it easy to manipulate arrays.
Defined:
The array contains two items per entity: Key and value, which can be obtained by querying the key.
The array can be numbered or correlated, that is, the elements of the array can be distinguished to visit PHP based on the number index or normalized string. the array can contain scalar (integer, Boolean, string, floating point number) or composite
I. Initialization of the numeric index array $ arr = array ('123', '123', '123'); the code above creates an array and contains three values. The numeric index of the PHP array starts from 0. Therefore, the value of $ arr [0] is 100. You can copy the
PHP array 1. Numeric index array 1.1 create an arrayThe two most commonly used types in PHP are: arrays, strings. There are two types of arrays, one is a numeric index, one is the key is the index, and the keyword index is a bit like the meaning of
PhpArray Sorting
The elements in the array can be sorted in descending or ascending order, in alphabetical or numerical terms.
PHP-Array sorting functionIn this chapter, we will introduce the following PHP array sorting functions:
PHP has some functions for sorting arrays, and this document lists them.The main differences are:
Some functions are sorted based on the keys of the array, while others are sorted based on values:$array [' key '] = ' value ';.
Php string functions, which are commonly used in php.
Php string functions, which are commonly used in php.
1. character location search function:
Strpos ($ str, search, [int]): searches for the first position of search in $ str starting from
PHP array sorting instances and functionsThe array in the PHP4 function manual is complete. I will check the latest manual tomorrow ....Array_values ($ arr) arrayReturns all elements of the array.Copy the code-PHP100.com $ Arr = array ("a", "B", "c "
$arr =array (11=>2530,13=>8922,26=>250,77=>250,88=>1230,99=>12);
The above array, how to remove the smallest three items:
Array (99=>12,26=>250,77=>250)
Reply to discussion (solution)
$arr =array ( 11=>2530, 13=>8922, 26
What is an array? An array is a programming structure. It is a variable that stores a group or a series of values.For example, personal identity registration during census, such as name, gender, ethnicity, and birth, can be used as an array.The
PHP array Chinese sorting, file format generally with UTF8, directly with the asort sort not. If GBK and gb2312 can. It's about coding. The encoding of GBK and gb2312 itself is sorted by pinyin.
. The code is as follows:
Function Utf8_array_asort (
1 Find character position function:
Strpos ($str, Search,[int]): Find the first position of search in $str starting from int;
Stripos ($str, search,[int]): function returns the position where the string first appears in another string. This function
1, quickly create an array of functions range ()For example, the range () function can quickly create an array of numbers from 1 to 9:
Copy Code code as follows:
$numbers =range (1,9);
echo $numbers [1];
?>
Of course, using
This chapter describes several common internal functions of the PHP array.
In the previous we have introduced the PHP array, created an array with the arrays () function, deletes an array element with the unset () function. In this chapter we will
Array_values ($arr) array
Returns all elements of an array
Copy Code code as follows:
$arr = Array ("A", "B", "C");
$arr = Array_flip ($arr); Reverses the subscript and value of an array now $arr = Array (0, 1, 2);
$arr =
1. Copying of arraysPointer-pointing problem when copying an array.When the array is copied, the position of the pointer is copied "This copy is exactly the same"However, if the pointer to the copied array is illegal, the position where the new
I think to be able to write an algorithm independently, it must be in writing code before the idea. Time Complexity (O (Nlog (n)))Idea: Select the middle value of the array, the left and right recursion, which merges two ordered arrays, and finally
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.