【发布时间】:2017-09-22 10:18:00
【问题描述】:
var_dump($locations);
显示:
array(1) {
[0]=> object(WP_Term)#3193 (10) {
["term_id"]=> int(11)
["name"]=> string(15) "Agence Himalaya"
["slug"]=> string(15) "agence-himalaya"
["term_group"]=> int(0)
["term_taxonomy_id"]=> int(11)
["taxonomy"]=> string(8) "location"
["description"]=> string(0) ""
["parent"]=> int(0)
["count"]=> int(1)
["filter"]=> string(3) "raw"
}
}
我需要在这个数组中获取["name"] 值
我尝试了$locations[0]["name"] 和不同的东西,但我没有设法获得物品的价值。
雨果
【问题讨论】:
-
$locations[0]->name? -
谢谢,它成功了,我得到了字符串(15)“Agence Himalaya”。有没有办法只获取字符串?
-
@Hugo M.,请把你的数组像 print_r($locations) 放在你的问题中......
-
因为你使用了vardump。它也会打印结果的类型。只需使用
echo只打印字符串 -
@amow 你说得对,作为初学者我不知道 :)