Hongmu Notes
Home Language Notes Does a PHP array exist within another array?
Language Notes PHP

Does a PHP array exist within another array?

Does a PHP array exist within another array?

To check whether one PHP array is contained within another PHP array, you can use the following code:

if(array_intersect($array1, $array2) == $array1){
   // $array1 is a subset of $array2
}

Used here array_intersect() Use a function to compare two arrays and find their intersection. If $array1 is a subset of $array2, then their intersection should be equal to $array1.

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

PHP ob function record

PHP ob function record Language Notes PHP

Usage of the following three functions ob_get_contents(); ob_end_clean(); ob_start(); You can use these functions to buffer local files and execute local script code. Use ob_start() to save the output code into the buffer, and the page will not be displayed; then use ob_get_contents to get the data in the buffer. o…
👁 141
PHP preg

PHP preg Language Notes PHP

The preg_match_all function is used to perform a global regular expression match. preg_match_all() Syntax int preg_match_all ( string $pattern , string $subject [, array &$matches [, int $flags = PREG…
👁 169
Detailed explanation of PHP ternary operator and if

Detailed explanation of PHP ternary operator and if Language Notes PHP

Ternary operator condition ? Result 1 : Result 2 Explanation: The position in front of the question mark is the condition for judgment. If the condition is met, the result is 1, and if it is not met, the result is 2. This article compares and explains the ternary operator and if...else... in detail. I hope it will be helpful to everyone. Today when I was revising my paper online, I encountered a statement that I couldn’t understand: $if_summary = $row['IF_SUMMARY']=…
👁 190
PHP cast type

PHP cast type Language Notes PHP PHP collection PHP and mysql

Get the data type 1. If you want to check the value and type of an expression, use var_dump(). 2. If you just want to get an easy-to-read type expression for debugging, use gettype(). 3. To check a certain type, do not use gettype(), but use the is_type() function. Converting Strings to Numbers When a string is evaluated as a number, the result is determined according to the following rules...
👁 232

Recommended reading

Industrial electronic components service provider website template 0004

Industrial electronic components service provider website template 0004 Practical Collection Yiyou template

This set of eyoucms templates is suitable for industrial electronic component service providers. The design style has a strong sense of technology and the information level is clear. It is suitable for displaying electronic component products, technical support and solutions, and helps electronic component distributors or manufacturers to establish their brand image online and expand industrial customers. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Yiyou CMS installation common...
👁 68
(Adaptive Mobile Version) Large-screen, professional water purification device website – PBootCMS template; Smart electronic device website source code download – 0435

(Adaptive Mobile Version) Large-screen, professional water purification device website – PBootCMS template; Smart electronic device website source code download – 0435 Practical Collection pbootcms Template

This set includes an adaptive, wide-screen water purification system for mobile devices and a smart electronic device – PbootCMS website template. The modern, tech-driven design is ideal for showcasing water purification products, smart hardware, and related solutions. It helps water purification brands effectively present their products online and attract both residential and commercial customers. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.c...
👁 32
Responsive Essay Writing Sample Website Template 0781

Responsive Essay Writing Sample Website Template 0781 Practical Collection Yiyou template

An EyouCMS responsive website template designed for essay writing and work sample documents. Its clean and practical design enables users to access a variety of sample essays, work templates, writing materials, and downloadable resources. This template helps educational content platforms attract both students and professionals online. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (E...
👁 57
Grains and agricultural products adaptive website template 0005

Grains and agricultural products adaptive website template 0005 Practical Collection Yiyou template

An eyoucms adaptive website template designed for grain and agricultural products enterprises. The design style is natural and fresh, which can well display cereal products, planting bases and brand stories. It helps agricultural enterprises establish their brand image online and expand sales channels for agricultural products. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Summary of common problems in Yiyou CMS installation...
👁 55
(Adaptive Mobile Version) Mechanical Manufacturing Website – PBootCMS Template; Blue Industrial Machinery and Equipment Website Source Code Download – 0436

(Adaptive Mobile Version) Mechanical Manufacturing Website – PBootCMS Template; Blue Industrial Machinery and Equipment Website Source Code Download – 0436 Practical Collection pbootcms Template

An adaptive mobile-friendly PbootCMS website template designed for mechanical manufacturing and blue-collar industrial machinery enterprises, ideal for showcasing their product ranges. It helps machinery companies build an online brand presence and attract industrial clients. Template Overview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 62
Social and民生新闻博客网站模板 0782

Social and民生新闻博客网站模板 0782 Practical Collection Yiyou template

This EyouCMS template is ideal for social affairs and news blog websites, featuring a feed-based design that aggregates trending social topics, public affairs updates, in-depth reports, and commentary articles. It helps news media attract online readers and build social influence. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS (Ey...
👁 61