Answer the question
In order to leave comments, you need to log in
How to check by key?
Good afternoon, there is such an array in php
array(2) {
[0]=>
array(4) {
["category_id"]=>
string(3) "137"
["name"]=>
string(49) "Лента термоуплотнительная"
["children"]=>
array(0) {
}
["href"]=>
string(90) "http://site/index.php?route=product/category&path=1_134_135_136_137"
}
[1]=>
array(4) {
["category_id"]=>
string(3) "138"
["name"]=>
string(89) "Огнезащита для воздуховодов с применением матов"
["children"]=>
array(0) {
}
["href"]=>
string(90) "http://site.ru/index.php?route=product/category&path=1_134_135_136_138"
}
}
Answer the question
In order to leave comments, you need to log in
$array = [/* ... */];
if (arrHasChildren($array)) {
// doSomeThing();
}
function arrHasChildren(array $array): bool
{
foreach ($array as $value) {
if (!empty($value['children'])) {
return true;
}
}
return false;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question