public static function findChildren(&$father, $array, $list, $noSub = false, $posible = [])
{
foreach ($array as $row) {
if (strpos($row['id'], $list) === false) {
if ($noSub) {
if ($row['category_id'] == $noSub) {
$list = self::findChildren($father, $array, $list, $row['id']);
$father[] = $row['id'];
$list .= $row['id'] . '-';
}
} elseif (count($posible) && array_key_exists($row['id'], $posible) && $row['category_id'] == $father['id']) {
$list = self::findChildren($row, $array, $list);
$row['numProducts'] = $posible[$row['id']];
$father['sub'][] = $row;
$list .= $row['id'] . '-';
} elseif ($row['category_id'] == $father['id']) {
$list = self::findChildren($row, $array, $list);
$father['sub'][] = $row;
$list .= $row['id'] . '-';
} else {
continue;
}
}
}
return $list;
}