php 比较2个数组,比较2个数组中的2个数组值Php
我刪除了舊帖子以使其更清晰.我有2個數(shù)組,我需要比較和匹配,但只有每個數(shù)組2個值相同.
$array1 = $plugins
$array2 = $xml_dump
兩個數(shù)組的樣本:
$plugins
Array
(
[all] => Array
(
[ajax-category-dropdown/dhat-ajax-cat-dropdown.php] => Array
(
[Name] => Ajax Category Dropdown
[PluginURI] => http://www.example.com/ajax/
[Version] => 0.1.5
[Description] => Generates multi-level ajax.
[Author] => DyasonHat
[AuthorURI] => http://www.dyasonhat.com
[Title] => Ajax Category Dropdown
[AuthorName] => Dya
)
[akismet/akismet.php] => Array
(
[Name] => Akismet
[PluginURI] => http://akismet.com/
[Version] => 2.5.3
[Description] => Used by millions
[Author] => Automattic
[AuthorURI] => http://automattic.com/
[Title] => Akismet
[AuthorName] => Automattic
)
$xml_dump
SimpleXMLElement Object
(
[plugin] => Array
(
[0] => SimpleXMLElement Object
(
[name] => Ajax Category Dropdown
[ex_version] => 0.1.5
[ex_date] => 2008-01-03
[plugin_url] => http://wordpress.org/extend/plugins/wp-contactform/
[advisory_url] => http://osvdb.org/show/osvdb/43284
)
[1] => SimpleXMLElement Object
(
[name] => WP-ContactForm
[ex_version] => 2.0.7
[ex_date] => 2008-01-03
[plugin_url] => http://wordpress.org/extend/plugins/wp-contactform/
[advisory_url] => http://osvdb.org/show/osvdb/43284
)
[2] => SimpleXMLElement Object
(
[name] => Math Comment Spam Protection
[ex_version] => 2.1
[ex_date] => 2008-01-03
[plugin_url] => http://wordpress.org/extend/plugins/math-comment-spam-protection/
[advisory_url] => a
)
僅當(dāng)$array1 Name,Version與$array2 name,ex_version匹配時,我才需要它返回值(或返回true)
在上面的示例中,您可以看到
$array1
Name => Ajax Category Dropdown
Version => 0.1.5
///has a match in
$array2
name => Ajax Category Dropdown
ex_version => 0.1.5
我已嘗試過array_intersect的許多變體,但我不能讓它匹配每個數(shù)組的2個值.
總結(jié)
以上是生活随笔為你收集整理的php 比较2个数组,比较2个数组中的2个数组值Php的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华硕推出 RT-AX82U 2023 5
- 下一篇: 必应集成 AI 对话,调查称不少用户开始