当前位置:网站首页>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>";
}
?>边栏推荐
- Spirit breath development log (15)
- What is the implementation of domain name to IP address conversion? What are the benefits of switching to a website?
- Ext4 file system jam caused by MEM CGroup OOM
- Develop a customized music player from scratch, and your girlfriend will have it?
- Before creating an image, it is recommended to execute the following code to purify the image as an administrator
- What domain name does not need to be filed? What should be done for domain name filing
- Build personal leanote cloud notebook with Tencent cloud lightweight application server
- Zhang Xiaodan, chief architect of Alibaba cloud hybrid cloud: evolution and development of government enterprise hybrid cloud technology architecture
- How to create a virtual machine on vSphere client -- a reliable virtual machine creation tutorial
- Find the current index of gbase 8C database?
猜你喜欢

Analyzing the superiority of humanoid robot in the post human era

014_ TimePicker time selector

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

Intensive learning and application of "glory of the king" to complete the application of 7 real worlds other than human players

011_ Cascader cascade selector

Let children learn the application essence of steam Education

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

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

CTF learning notes 17:iwesec file upload vulnerability-02 file name filtering bypass

Leetcode (question 1) - sum of two numbers
随机推荐
PHP sort() function
5g and industrial Internet
Qiming cloud sharing: tips on esp32c3 simple IO and serial port
Open source and SaaS, how to choose software?
Elfk service setup
System design: Agent & redundancy & replication
Spirit breath development log (9)
Develop a customized music player from scratch, and your girlfriend will have it?
IP and traffic reconciliation tool networktrafficview
How to clone virtual machines on vspere client
Pg-pool-ii read / write separation experience
How can the website be broken by CC attack?
Drawing axes with dates using Matplotlib
Eigen eigenMatrix
Popularization of children's programming education in specific scenarios
What are the functions and advantages of the Internet of things cloud platform?
NAT
3 minutes to understand JSON schema
What server does domain name and IP address convert through? How does the server convert?
Performance comparison of JS loop traversal methods: for/while/for in/for/map/foreach/every