当前位置:网站首页>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>";
}
?>边栏推荐
- Why domain name should be resolved? What is the domain name registration query
- How to create a virtual machine on vSphere client -- a reliable virtual machine creation tutorial
- Develop a customized music player from scratch, and your girlfriend will have it?
- Inventory of common tools used by dry goods | data journalists
- Customer disaster recovery case - a MySQL database migration scheme
- Is it useful to build an industrial knowledge map platform?
- What is stored in the domain name server? How does the domain name server provide services?
- Use of go testing framework gomock
- What's wrong with the failure of uploading web pages to ECS? How many kinds of servers are there
- 014_ TimePicker time selector
猜你喜欢

Loss and optimization of linear regression, machine learning to predict house prices

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

少儿编程课程改革后的培养方式

014_ TimePicker time selector

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

Leetcode (question 1) - sum of two numbers

Popularization of children's programming education in specific scenarios

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

Introduction to the "penetration foundation" cobalt strike Foundation_ Cobalt strike linkage msfconsole

解析后人类时代类人机器人的优越性
随机推荐
LeetCode 1290. Binary linked list to integer
Understanding OAuth 2.0
Panoramic recording, WYSIWYG new recording scheme, and exclusive preferential resource package as low as 1 yuan!
Troubleshooting for the error message "[err] mod\u local\u stream.c:880 unknown source default" in easyrtc
Verifying data models in golang
CTF learning notes 17:iwesec file upload vulnerability-02 file name filtering bypass
Redis pipeline technology speed and efficiency increased by 5 times
How can the website be broken by CC attack?
What is cloud server? How to access the ECS Homepage
Tencent cloud + community video [technology star push official] FAQ
oracle数据库提示无操作权限的问题
What domain names do not need to be filed? Is there any process for domain name registration
System design: index
Bi-sql where
Analysis of electronic signature system
Spirit breath development log (9)
Drawing axes with dates using Matplotlib
What is the implementation of domain name to IP address conversion? What are the benefits of switching to a website?
What is stored in the domain name server? How does the domain name server provide services?
Implementation principle of Flink connector mongodb CDC