У меня есть ассоциативный массив, который содержит список тегов из WordPress Post. Это выход из WordPress Функции wp_get_post_tagsЧтобы проверить, имеет ли ассоциативный массив определенное значение
array(3) { [0]=> object(WP_Term)#300 (10) { ["term_id"]=> int(22) ["name"]=> string(10) "Case Study" ["slug"]=> string(10) "case-study" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(22) ["taxonomy"]=> string(8) "post_tag" ["description"]=> string(0) "" ["parent"]=> int(0) ["count"]=> int(6) ["filter"]=> string(3) "raw" } [1]=> object(WP_Term)#295 (10) { ["term_id"]=> int(9) ["name"]=> string(9) "Microsoft" ["slug"]=> string(9) "microsoft" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(9) ["taxonomy"]=> string(8) "post_tag" ["description"]=> string(0) "" ["parent"]=> int(0) ["count"]=> int(11) ["filter"]=> string(3) "raw" } [2]=> object(WP_Term)#367 (10) { ["term_id"]=> int(27) ["name"]=> string(10) "SharePoint" ["slug"]=> string(10) "sharepoint" ["term_group"]=> int(0) ["term_taxonomy_id"]=> int(27) ["taxonomy"]=> string(8) "post_tag" ["description"]=> string(0) "" ["parent"]=> int(0) ["count"]=> int(10) ["filter"]=> string(3) "raw" } }
, и я хочу, чтобы проверить, содержит ли он имя тега «SharePoint». Я прошел через различные ресурсы, но не могу найти способ сделать это. Это структура массива
Array
(
[0] => stdClass Object
(
[term_id] => 4
[name] => tag2
[slug] => tag2
[term_group] => 0
[term_taxonomy_id] => 4
[taxonomy] => post_tag
[description] =>
[parent] => 0
[count] => 7
)
[1] => stdClass Object
(
[term_id] => 7
[name] => tag5
[slug] => tag5
[term_group] => 0
[term_taxonomy_id] => 7
[taxonomy] => post_tag
[description] =>
[parent] => 0
[count] => 6
)
[2] => stdClass Object
(
[term_id] => 16
[name] => tag6
[slug] => tag6
[term_group] => 0
[term_taxonomy_id] => 16
[taxonomy] => post_tag
[description] =>
[parent] => 0
[count] => 2
)
)
Я попытался сделать это, но он не работает
//$a is the Array
foreach ($a as $key=>$value) {
if ($value=='SharePoint'){
echo "True"
}
Просьба помочь.