This article mainly share with you the PHP part of the function of the detailed, mainly in the way of code and we share, hope to help everyone.
1, Array_diff_assoc ($arr 1, $arr 2, $arr 3 ...) function: Compare the key names and key values of two arrays and return the difference set
Cases:
<?php$a1=array ("2" = "This_2", "3" = "This_3", "4" = "This_4", "5" and "this_5"); $a 2=array ("1" = "This _1 "," 2 "=" This_2 "," 3 "=" This_3 "), $result 1 = ARRAY_DIFF_ASSOC ($a 1, $a 2); The array can be exchanged sequentially, or it can be multiple arrays var_dump ($result 1); >
Printing results:
Array (size=2) 4 = String ' This_4 ' (length=6) 5 = String ' This_5 ' (length=6)
2. Array_keys () function: Returns a new array containing all the key names in the array
Cases:
<?php$a1=array ("2" = "This_2", "3" = "This_3", "4" = "This_4", "5" and "This_5"); $result 2 = Array_keys ($a 1 ); Var_dump ($result 2);? >
Printing results:
Array (size=4) 0 = int 2 1 = int 3 2 = int 4 3 = int 5
3. Array_key_exists () Function: Checks whether the specified key name exists in an array, returns true if the key name exists, or False if the key name does not exist.
Cases:
<?php$a1=array ("2" = "This_2", "3" = "This_3", "4" = "This_4", "5" and "this_5"); if (Key_exists ("2", $a 1)) {echo "yes!";} Else{echo "no!";}? >
Output Result:
yes!
4. Sort () function: Sorts the array in ascending order
5. Rsort () function: Sort in descending order of array
6. Asort () function: sort associative arrays in ascending order based on values
7. Ksort () function: Sort the associative array in ascending order according to the key
8. Arsort () function: sort associative arrays in descending order based on values
9. Krsort () function: Sort the associative array in descending order according to the key
10. Count () function: Returns the number of elements in an array
Cases:
<?php$a1=array ("2" = "This_2", "3" = "This_3", "4" = "This_4", "5" and "This_5"); $result 3 = count ($a 1); echo $result 3;? >
Output Result:
4