Php 嵌套数组中的Gwt数据字符串
我有一个包含大量嵌套数组数据的数组。 我需要得到: 数组(4){[“id”]=>int(90)Php 嵌套数组中的Gwt数据字符串,php,arrays,Php,Arrays,我有一个包含大量嵌套数组数据的数组。 我需要得到: 数组(4){[“id”]=>int(90) 这个数字是90。 请参见下面的整个阵列数据。 非常感谢你的帮助 array(2) { ["_sft_product_cat"]=>array(5) { ["name"]=> string(18) "Produkt-Kategorien" ["singular_name"]=> string(9) "Kateg
这个数字是90。 请参见下面的整个阵列数据。 非常感谢你的帮助
array(2)
{ ["_sft_product_cat"]=>array(5)
{
["name"]=> string(18)
"Produkt-Kategorien"
["singular_name"]=> string(9)
"Kategorie"
["all_items_label"]=> string(15)
"Alle Kategorien"
["type"]=> string(8)
"taxonomy"
["active_terms"]=> array(1)
{ [0]=> array(4)
{ ["id"]
=> int(90) ["name"]
=> string(7) "Hyundai" ["value"]
=> string(7) "hyundai" ["count"]
=> int(0)
}
}
}
["_sft_pa_typ"]=> array(5)
{ ["name"]
=> string(18) "Produkt Typ/Modell" ["singular_name"]
=> string(10) "Typ/Modell" ["all_items_label"]
=> string(5) "Al le " ["type"]
=> string(8) "taxonomy" ["active_terms"]
=> array(1)
{ [0]=> array(4)
{ ["id"]
=> int(9040) ["name"]
=> string(8) "Coupe GK" ["value"]
=> string(8) "coupe-gk" ["count"]=> int(0) } } } }
我不熟悉php,但首先我会格式化和缩进代码,以便更好地了解嵌套对象的需求:
array(2) {
["_sft_product_cat"]=> array(5)
{
["name"]=> string(18) "Produkt-Kategorien"
["singular_name"]=> string(9) "Kategorie"
["all_items_label"]=> string(15) "Alle Kategorien"
["type"]=> string(8) "taxonomy"
["active_terms"]=> array(1)
{
[0]=> array(4)
{
["id"]=> int(90)
["name"]=> string(7) "Hyundai"
["value"]=> string(7) "hyundai"
["count"]=> int(0)
}
}
}
["_sft_pa_typ"]=> array(5)
{
["name"]=> string(18) "Produkt Typ/Modell"
["singular_name"]=> string(10) "Typ/Modell"
["all_items_label"]=> string(5) "Alle "
["type"]=> string(8) "taxonomy"
["active_terms"]=> array(1)
{
[0]=> array(4)
{
["id"]=> int(9040) ["name"]=> string(8) "Coupe GK"
["value"]=> string(8) "coupe-gk" ["count"]=> int(0)
}
}
}
}
这会让我相信你在寻找身份证:
或
[0][4][0][0]
我不熟悉php,但首先我会格式化并缩进代码,以便更好地了解您需要从嵌套对象中获得什么:
array(2) {
["_sft_product_cat"]=> array(5)
{
["name"]=> string(18) "Produkt-Kategorien"
["singular_name"]=> string(9) "Kategorie"
["all_items_label"]=> string(15) "Alle Kategorien"
["type"]=> string(8) "taxonomy"
["active_terms"]=> array(1)
{
[0]=> array(4)
{
["id"]=> int(90)
["name"]=> string(7) "Hyundai"
["value"]=> string(7) "hyundai"
["count"]=> int(0)
}
}
}
["_sft_pa_typ"]=> array(5)
{
["name"]=> string(18) "Produkt Typ/Modell"
["singular_name"]=> string(10) "Typ/Modell"
["all_items_label"]=> string(5) "Alle "
["type"]=> string(8) "taxonomy"
["active_terms"]=> array(1)
{
[0]=> array(4)
{
["id"]=> int(9040) ["name"]=> string(8) "Coupe GK"
["value"]=> string(8) "coupe-gk" ["count"]=> int(0)
}
}
}
}
这会让我相信你在寻找身份证:
或
[0][4][0][0]
您正在寻找:
$whatever_your_var_name_is["_sft_product_cat"]["active_terms"][0]["id"]
这与逐个引用标高相同
$sft_product_cat = $whatever_your_var_name_is['_sft_product_cat'];
$active_terms = $sft_product_cat['active_terms'];
$first_terms = $active_terms[0];
$id = $first_terms['id'];
值得注意的是,活动的\u术语有一个数字索引数组(即[0]部分)。这意味着“\u sft\u product\u cat”的其他实例可能有多个术语,您需要一个循环来获取它们。您正在查找:
$whatever_your_var_name_is["_sft_product_cat"]["active_terms"][0]["id"]
这与逐个引用标高相同
$sft_product_cat = $whatever_your_var_name_is['_sft_product_cat'];
$active_terms = $sft_product_cat['active_terms'];
$first_terms = $active_terms[0];
$id = $first_terms['id'];
值得注意的是,活动项有一个数字索引数组(即[0]部分)。这是一个提示,“\u sft\u product\u cat”的其他实例可能有多个术语,您需要一个循环来获取所有术语。这是正确的。感谢您格式化我的代码。但不幸的是,ma PHP知识是一场灾难。我从几个小时以来一直在阅读PHP文章,但无法获得所需的值:)这是正确的。谢谢您的帮助整理我的代码。但不幸的是,掌握PHP知识是一场灾难。我从几个小时以来一直在阅读PHP文章,但无法获得所需的值:)我构建数组是为了更好地查看它的实际外观我构建数组是为了更好地查看它的实际外观