这是我的对象,我想要获取每个选项卡中的字段数。我反正这里想跳过场如果它的类型是一个选项卡,然后开始标签的下一类型之前计算领域的..如何获取组选项卡对象中每个字段的计数
低于我的目标:
array(49) {
[0]=>
array(12) {
["key"]=>
string(19) "field_596796ae0c4c4"
["label"]=>
string(7) "GENERAL"
["name"]=>
string(0) ""
["_name"]=>
string(0) ""
["type"]=>
string(3) "tab"
["order_no"]=>
int(0)
["instructions"]=>
string(0) ""
["required"]=>
int(0)
["id"]=>
string(10) "acf-field-"
["class"]=>
string(3) "tab"
["conditional_logic"]=>
array(3) {
["status"]=>
int(0)
["rules"]=>
array(1) {
[0]=>
array(3) {
["field"]=>
string(19) "field_5964e9dd6df85"
["operator"]=>
string(2) "=="
["value"]=>
string(0) ""
}
}
["allorany"]=>
string(3) "all"
}
["field_group"]=>
int(165)
}
[1]=>
array(18) {
["key"]=>
string(19) "field_5964e9206df82"
["label"]=>
string(5) "Brand"
["name"]=>
string(5) "brand"
["_name"]=>
string(5) "brand"
["type"]=>
string(8) "taxonomy"
["order_no"]=>
int(1)
["instructions"]=>
string(0) ""
["required"]=>
int(1)
["id"]=>
string(15) "acf-field-brand"
["class"]=>
string(8) "taxonomy"
["conditional_logic"]=>
array(3) {
["status"]=>
int(0)
["rules"]=>
array(1) {
[0]=>
array(3) {
["field"]=>
string(19) "field_5964e9dd6df85"
["operator"]=>
string(2) "=="
["value"]=>
string(7) "regular"
}
}
["allorany"]=>
string(3) "all"
}
["taxonomy"]=>
string(8) "pa_brand"
["field_type"]=>
string(6) "select"
["allow_null"]=>
int(0)
["load_save_terms"]=>
int(0)
["return_format"]=>
string(2) "id"
["field_group"]=>
int(165)
["multiple"]=>
int(0)
}
[2]=>
array(12) {
["key"]=>
string(19) "field_596796da0c4c5"
["label"]=>
string(6) "LAUNCH"
["name"]=>
string(0) ""
["_name"]=>
string(0) ""
["type"]=>
string(3) "tab"
["order_no"]=>
int(2)
["instructions"]=>
string(0) ""
["required"]=>
int(0)
["id"]=>
string(10) "acf-field-"
["class"]=>
string(3) "tab"
["conditional_logic"]=>
array(3) {
["status"]=>
int(0)
["rules"]=>
array(1) {
[0]=>
array(3) {
["field"]=>
string(19) "field_5964e9dd6df85"
["operator"]=>
string(2) "=="
["value"]=>
string(0) ""
}
}
["allorany"]=>
string(3) "all"
}
["field_group"]=>
int(165)
}
[3]=>
array(15) {
["key"]=>
string(19) "field_5964e99e6df84"
["label"]=>
string(20) "Announced (Globally)"
["name"]=>
string(18) "announced_globally"
["_name"]=>
string(18) "announced_globally"
["type"]=>
string(11) "date_picker"
["order_no"]=>
int(3)
["instructions"]=>
string(23) "Date globally announced"
["required"]=>
int(0)
["id"]=>
string(28) "acf-field-announced_globally"
["class"]=>
string(11) "date_picker"
["conditional_logic"]=>
array(3) {
["status"]=>
int(0)
["rules"]=>
array(1) {
[0]=>
array(3) {
["field"]=>
string(19) "field_5964e9dd6df85"
["operator"]=>
string(2) "=="
["value"]=>
string(7) "regular"
}
}
["allorany"]=>
string(3) "all"
}
["date_format"]=>
string(4) "mmyy"
["display_format"]=>
string(5) "MM yy"
["first_day"]=>
int(1)
["field_group"]=>
int(165)
}
或本反对我简化,在Javascript运行:
var productObject = [
{
"type":"tab",
"value":"GENERAL"
},
{
"type":"taxonomy",
"value":"56",
"label":"Brand"
},
{
"type":"tab",
"value":"LAUNCH"
},
{
"type":"text",
"name":"announced_ph",
"label":"Announced(Philippines)",
"value":"07072017"
},{
"type":"text",
"name":"announced_global",
"label":"Announced(Global)",
"value":"09092017"
},{
"type":"tab",
"value":"NETWORK"
},{
"type":"text",
"name":"sim_type",
"label":"SIM",
"value":"dualnano"
},{
"type":"text",
"name":"broadband_speed",
"label":"Broadband Speed",
"value":"LTE Cat6"
},{
"type":"text",
"name":"broadband_speed",
"label":"Broadband Speed",
"value":"LTE Cat6"
}
];
我需要知道田/有型的“标签”的对象后,对象的数量。因为我需要知道它对于我的表的rowspan值。
我想在输出中应该是:
Tab "General" has 1 field
Tab "Launch" has 2 field
Tab "Network" has 3 field
谢谢!