I want to show children category inside parent category
I'm using $categories
to get arrays like this:
[5] => Array
(
[id] => 5
[parent_id] => 4
)
[4] => Array
(
[id] => 5
[parent_id] => 0
)
[3] => Array
(
[id] => 3
[parent_id] => 1
)
[1] => Array
(
[id] => 1
[parent_id] => 0
)
And i'm using this code to check if category have a children
if (array_search($category['id'], array_column($categories, 'parent_id'))) {
echo "This category has children";
}
get arrays from database
$categories = load_categories(array('db_table' => 'pm_categories'));
So can help me to get id of array where find parent_id