Php array function in_array () to find whether the array value exists
In php programming, the in_array () function searches for the given value in the array.In_array () defines and uses the in_array () function to search for a given value in the array.The description value of the in_array (value, array, type) parameter is required. Specifies the value to be searched in the array. Array is required. Specifies the array to be searched. Type is optional. If this parameter is set to true, c
the factory supervisor gave Xiao Chen a picture of the production plant of the product family."You see, if you want to produce a series of product family products, you just have to put the product line together." "Now let's take a look at the template code for the specific product line: for example, we're going to produce a knight's product and the Thunder Team product, and the product includes a badge and sneakers for the time being.1, an abstract interface, specifically for the production of
['Peter '] = "32 "; $ ages ['quagmire'] = "30"; $ ages ['job'] = "34"; you can use the ID key in the script:
Output of the above script: Peter is 32 years old. multi-dimensional array in multi-dimensional array, each element in the main array is also an array. Each element in the sub-array can also be an array, and so on. Example 1 in this example, we create a multidimensional array with an automatically assigned ID key: $ families = array ("Griffin in" => array ("Peter ", "Lois", "Megan"), "Q
another way to create an array: $ ages ['Peter '] = "32 "; $ ages ['quagmire'] = "30"; $ ages ['job'] = "34"; you can use the ID key in the script:
Output of the above script: Peter is 32 years old. multi-dimensional array in multi-dimensional array, each element in the main array is also an array. Each element in the sub-array can also be an array, and so on. Example 1 in this example, we create a multidimensional array with an automatically assigned ID key: $ families = array ("Griffin in" =
array, and so on.Example 1
In this example, we create a multidimensional array with an automatically assigned ID key:
$families = array( "Griffin"=>array ( "Peter", "Lois", "Megan" ), "Quagmire"=>array ( "Glenn" ), "Brown"=>array ( "Cleveland", "Loretta", "Junior" ));
If this array is output, it should be similar to the following:
Array([Griffin] => Array ( [0] => Peter [1] => Lois [2] => Megan )[Quagmire] => Array ( [0] => Gle
Definition and usage
The end () function points the array's internal pointer to the last element and returns the value of the element, if successful.
Grammar
End (Array) parameter description
Array required. Specifies the array to use.
Example
Copy the Code code as follows:
$people = Array ("Peter", "Joe", "Glenn", "Cleveland");Echo current ($people). "";Echo End ($people);?>
Output:
Peter
Cleveland
'] = "30 ";$ Ages ['job'] = "34 ";
You can use the ID key in the script:
The code is as follows:
$ Ages ['Peter '] = "32 ";$ Ages ['quagmire'] = "30 ";$ Ages ['job'] = "34 ";Echo "Peter is". $ ages ['Peter ']. "years old .";?>
Output of the above script:Peter is 32 years old.Multi-dimensional array In a multi-dimensional array, each element in the main array is also an array. Each element in the sub-array can also be an array, and so on.Example 1In this example, we create a multidimensional ar
in the script:Copy codeThe Code is as follows: $ Ages ['Peter '] = "32 ";$ Ages ['quagmire'] = "30 ";$ Ages ['job'] = "34 ";
Echo "Peter is". $ ages ['Peter ']. "years old .";?>
Output of the above script:
Peter is 32 years old.
Multi-dimensional array In a multi-dimensional array, each element in the main array is also an array. Each element in the sub-array can also be an array, and so on.
Example 1In this example, we create a multidimensional array with an automatically assigned ID
In_array () Definition and usage
The in_array () function finds whether a specified value exists in the array.
SyntaxIn_array (value, array, type) parameter descriptionValue is required. Specifies the value to be searched in the array.Array is required. Specifies the array to be searched.Type is optional. If this parameter is set to true, check whether the data to be searched is of the same type as the value of the array.
DescriptionReturns true if the given value exists in the array. If the t
";Echo "Peter is". $ ages ['Peter ']. "years old .";?>Output of the above script:Peter is 32 years old. Multi-dimensional arrayIn a multi-dimensional array, each element in the main array is also an array. Each element in the sub-array can also be an array, and so on.Example 1In this example, we create a multidimensional array with an automatically assigned ID key: The code is as follows:Copy code $ Families = array("Griffin in" => array ("Pe
In_array(PHP 4, PHP 5)In_array-Check if an array of values existsDescribeBoolean In_array (mixed $ pin, array $ haystack [, Boolean $ strict])Search for haystack needles.ParametersNeedleThe value to search for.Note: If the needle is a string, this comparison is a case-sensitive way.HaystackArray.StrictIf the strict third argument is set to True, the In_array () function will also check all kinds of needles in a haystack.return valueReturns true if found in the pin array, except for false.ModifyV
Label: style blog HTTP use SP strong on 2014
Target Users: College Students
Comparison software: sogou input method (desktop Edition)
I. Functions: 1. Personal Name input:
I tried a lot of personal names and found that Bing and sogou are almost all complete word libraries for personal names,
When "wskt" is entered, Bing gives the correct name of the person, and the first candidate word in sogou is not the one we need.
A candidate word with the correct name does not appear
Necessary. User-defined functions.The function must be designed to return 1, 0, or 1, and should accept two parameters for comparison and work in a manner similar to the following:
If a = B, returns 0
If a > B, return 1
If a
ExampleOutput:Array ([0] = peter[1] = glenn[2] = cleveland[3] = peter[4] = glenn[5] = Cleveland)Example 2function compare ($a, $b) {
before it inserts any records.----TERMINATED by specifies , the data is TERMINATED by--commas, but may also is enclosed by quotation marks. Datatypes--For any fields, default to CHAR.----The names of columns to load is enclosed in parentheses.--If No datatype or length is specified and the field is delimited--with enclosed by or with TERMINATED by and then the default--datatype is CHAR and the default length is 255. If Enclosed by--or TERMINATED by isn't specified, then the default type is CHAR
In_array () Definition and usage
The In_array () function searches the array for a given value.
Grammar
In_array (Value,array,type)
Parameter description
Value required. Specify the values to search for in the array.
Array required. Specify the array to search for.
Type is optional. If this parameter is set to True, the search data is checked for the same type as the value of the array.
Description
Returns true if the value given is present in array arrays. If the third argument is set to True
calls:
Back: "->"-Method call
Back to::-static method call
Return Nothing-function call
Args
Array
If you are in a function, list the function arguments. If you are referencing a file, list the names of the referenced files.
Grammar
Debug_backtrace () example
Copy Code code as follows:
function One ($str 1, $str 2)
{
Two ("Glenn", "quagmire");
}
function two ($str 1, $str 2)
{
Three ("
Address table in table 1. Because the data is entered by the user, we cannot use data that has been unified to uppercase. To find every address named John, we use a query statement that contains the upper clause. As shown below:
Sql> Select Address the where upper (name) like ' JOHN ';
Before running this query statement, if we run the command "set Autotrace on", we get the following results, which include the execution process:
Address
/phper/php/39841.htm
Traverse
When traversing the list of users, simply query the username directly with Isset to see if it exists.
PHP Version Code:
The code is as follows
Copy Code
$arrayHash = Array ();foreach ($arrayN as $nameN) {The bank executed N times.$arrayHash [$nameN] = 1;}foreach ($arrayM as $keyM => $nameM) {if (Isset ($arrayHash [$nameM])) {The bank executed M times!Unset ($arrayM [$keyM]);}}return $arrayM;?>Multidimensional
Array
In a mul
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.