当前位置:网站首页>PHP in_ Array() function
PHP in_ Array() function
2022-06-24 05:11:00 【User 1448800】
example
Search for values in an array "Glenn" , And output some text :
<?php
$people = array("Bill", "Steve", "Mark", "David");
if (in_array("Mark", $people))
{
echo " Match found ";
}
else
{
echo " Match not found ";
}
?>Definition and Usage
in_array() The function searches the array for the specified value .
notes : If search The parameter is a string and type Parameter is set to TRUE, The search is case sensitive .
grammar
in_array(search,array,type)
Parameters | describe |
|---|---|
search | It's necessary . Specify the value to search in the array . |
array | It's necessary . Specify the array to search . |
type | Optional . If this parameter is set to true, Then check whether the data searched is of the same type as the value of the array . |
explain
If the given value search Exists in arrays array Middle returns true. If the third parameter is set to true, The function returns... Only if the element exists in the array and the data type is the same as the given value true.
If no parameters are found in the array , The function returns false.
notes : If search The argument is a string , And type Parameter set to true, The search is case sensitive .
Technical details
Return value : | Returns... If a value is found in the array TRUE, Otherwise return to FALSE. |
|---|---|
PHP edition : | 4+ |
Changelog: | since PHP 4.2 rise ,search Parameters can now also be arrays . |
More instances
Example 1
Use all parameters :
<?php
$people = array("Bill", "Steve", "Mark", "David");
if (in_array("23", $people, TRUE))
{
echo " Match found <br>";
}
else
{
echo " Match not found <br>";
}
if (in_array("Mark",$people, TRUE))
{
echo " Match found <br>";
}
else
{
echo " Match not found <br>";
}
if (in_array(23,$people, TRUE))
{
echo " Match found <br>";
}
else
{
echo " Match not found <br>";
}
?>边栏推荐
- 少儿编程教育在特定场景中的普及作用
- 3 minutes to understand JSON schema
- Deep learning common optimizer summary
- Hard core observation 553 AI needs to identify almost everyone in the world with hundreds of billions of photos
- Zhang Xiaodan, chief architect of Alibaba cloud hybrid cloud: evolution and development of government enterprise hybrid cloud technology architecture
- What is stored in the domain name server? How does the domain name server provide services?
- Bi-sql insert into
- 『渗透基础』Cobalt Strike基础使用入门_Cobalt Strike联动msfconsole
- Use of go testing framework gomock
- Share 10 creative projects of Gaoxing!
猜你喜欢

Leetcode question brushing (question 3) - the longest substring without repeated characters

Let children learn the application essence of steam Education

Leetcode (question 1) - sum of two numbers

Analysis on the subjective enthusiasm of post-90s makers' Education

Leetcode (question 2) - adding two numbers

少儿编程教育在特定场景中的普及作用

What is the new generation cloud computing architecture cipu of Alibaba cloud?

Zhang Xiaodan, chief architect of Alibaba cloud hybrid cloud: evolution and development of government enterprise hybrid cloud technology architecture
![[leetcode daily question] push domino](/img/81/1c31e97d9a245816514bcf47c92107.jpg)
[leetcode daily question] push domino

Training methods after the reform of children's programming course
随机推荐
What are clustering, distribution, and microservices?
What server does domain name and IP address convert through? How does the server convert?
Bi-sql distinct
Share 10 creative projects of Gaoxing!
Shopify background XSS storage vulnerability
There are many ways to confirm and modify the remote port number
Find the current index of gbase 8C database?
Why do hybrid clouds exist?
How does a R & d make a small demand bigger and bigger step by step
Functional advantages of industrial wireless router
Bi-sql order by
Tencent conference rest API x-tc-registered parameter policy update notification
Customer disaster recovery case - a MySQL database migration scheme
Panoramic recording, WYSIWYG new recording scheme, and exclusive preferential resource package as low as 1 yuan!
Where is the cheaper domain name? What should I pay attention to when buying a domain name?
Jimureport building block report - expression introduction
LeetCode 1791. Find the central node of the star chart
Spirit breath development log (11)
Verifying data models in golang
What kind of domain name is better? What should enterprises pay attention to when choosing a domain name?