当前位置:网站首页>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>";
}
?>边栏推荐
- Shuttle global levitation button
- What are the functions and advantages of the Internet of things cloud platform?
- The trunk warehouse can also be tob, and Tencent cloud microenterprises do not leave quality behind
- 解析后人类时代类人机器人的优越性
- PHP uasort() function
- How to create a virtual machine on vSphere client -- a reliable virtual machine creation tutorial
- Tencent conference rest API x-tc-registered parameter policy update notification
- 014_ TimePicker time selector
- 『渗透基础』Cobalt Strike基础使用入门_Cobalt Strike联动msfconsole
- How the query address of cloud native monitoring data exposes the public network
猜你喜欢

『渗透基础』Cobalt Strike基础使用入门_Cobalt Strike联动msfconsole

Popularization of children's programming education in specific scenarios

Leetcode (question 2) - adding two numbers

让孩子们学习Steam 教育的应用精髓

011_ Cascader cascade selector

CTF learning notes 18:iwesec file upload vulnerability-03-content-type filtering bypass

解析后人类时代类人机器人的优越性

Zhang Xiaodan, chief architect of Alibaba cloud hybrid cloud: evolution and development of government enterprise hybrid cloud technology architecture

Hard core observation 553 AI needs to identify almost everyone in the world with hundreds of billions of photos

Loss and optimization of linear regression, machine learning to predict house prices
随机推荐
Some excellent plug-ins on Amway vscode
What kind of domain name is better? What should enterprises pay attention to when choosing a domain name?
Introduction to the "penetration foundation" cobalt strike Foundation_ Cobalt strike linkage msfconsole
Bi-sql and & or & in
The function of nearby people in the applet is realized, and the cloud development database is used to realize nearby people and friends within a distance of the neighborhood
How unity runs code every few frames
"Emergency response practice" logparser log analysis practice
Build your unique online image
Svg quick start small white article
解析后人类时代类人机器人的优越性
Skillfully compiling openwrt routing firmware with pay as you go ECS
Loss and optimization of linear regression, machine learning to predict house prices
Eigen eigenMatrix
How to control CDN traffic gracefully in cloud development?
IP and traffic reconciliation tool networktrafficview
Analysis of electronic signature system
Customer disaster recovery case - a MySQL database migration scheme
Analyzing the superiority of humanoid robot in the post human era
What's wrong with the failure of uploading web pages to ECS? How many kinds of servers are there
Precautions for online education and training industry filing