Delete php code for arrays and 2D array values. The method is as follows: $ arrarray (); assume that an array with 10 thousand elements contains repeated elements. $ Arrarray_flip (array_flip ($ arr); this allows you to delete duplicate elements.
In PHP, use list to extract the values in the array, such as list ($ a, $ B) $ array.
1. value extractionIn PHP, use list to extract the values in the array, such as list ($ a, $ B) = $ array. If the number of values in the list is greater than the
PHP deletes empty array values
Foreach ($ arr as $ k =>$ v ){
If (! $ V)
Unset ($ arr [$ k]);
}
?>
In addition, the self-feeling is quite good, but this efficiency is not very high. I
The example in this article describes the method that PHP recursively calls an array value and executes the specified function. Share to everyone for your reference. The specific analysis is as follows:
The following is the WordPress original code,
We can use bubble, quick row, select and other sorting methods to achieve array sorting, but sometimes we do not want to change the order of the array, just want to know its order, and then its subscript output, how should be implemented.
Simple
To put it bluntly, the null values removed from the array are strongly written into foreach or while. These two syntax structures are used to delete the empty elements in the array. The simple code is as follows:Copy codeThe Code is as
This article mainly introduces how to delete the empty values of arrays in PHP. For more information, see
This article mainly introduces how to delete the empty values of arrays in PHP. For more information, see
To put it bluntly, the null
In this paper, the use of smarty built-in function foreach is described and shared for everyone's reference. Specific as follows:
Display file: index.php:Copy the Code code as follows: Create a Smarty ObjectRequire_once ("./libs/smarty.class.php");$
Ashamed to say, before the null value of the array is either strong write foreach or while, using these two syntax structure to delete empty elements in the array, the simple code is as follows:
Copy CodeThe code is as follows:
foreach ($arr as $k
The array_search () function is the same as the in_array () function. You can find a key value in the array. If this value is found, the key name of the matching element is returned. If not found, false is returned.If the third parameter strict is
Copy Code code as follows:
$full _name = Array ();
$full _name["Roger"] = "Waters";
$full _name["Richard"] = "Wright";
$full _name["Nick"] = "Mason";
$full _name["David"] = "Gilmour";
To sort this array, you just use the
Copy CodeThe code is as follows:
$full _name = Array ();
$full _name["Roger"] = "Waters";
$full _name["Richard"] = "Wright";
$full _name["Nick"] = "Mason";
$full _name["David"] = "Gilmour";
To sort this array, you just use the Assort () function.
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
A peer is puzzled by the above program code, mainly because he does not understand the following code:
Code highlighting produced by Actipro
The array_search () function is the same as the in_array () function. You can find a key value in the array. If this value is found, the key name of the matching element is returned. If not found, false is returned.
The array_search () function is
This article mainly introduces the implementation of PHP to merge 2 numeric key array value method, involving PHP for array traversal, judgment, conversion and other related operations skills, the need for friends can refer to the following
In this
Array_unique("= 4.0.1, PHP 5" in PHP 4)Array_unique-delete an array of repeated valuesDescriptionArray array_unique (array $ array [Abstract $ sort_flags = SORT_REGULAR])Take an input array and return a new array with no repeated values.Note that
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.