My Array就是这个
stdClass Object
(
[lc_anuradhapura] => Array
(
[0] => attr_balapitiya-boat-rides
[1] => attr_bird-watching-in-kandalama
)
[lc_bentota] => Array
(
[0] => attr_city-tour
[1] => attr_colombo-national-museum
)
[lc_colombo] => Array
(
[0] => attr_cultural-show
[1] => attr_cycling
)
)
我需要检查'attr_cycling'是否在'lc_colmbo'中。但需要通过一个共同的循环动态检查。
答案 0 :(得分:2)
var found = false;
loop:
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
for (var j = 0; j < obj[i].length; j++) {
if (obj[i][j] === "attr_cycling") {
found = true;
break loop;
}
}
}
}