【发布时间】:2022-01-19 11:07:39
【问题描述】:
大家好,帮我解决这个问题,先谢谢了
class CategoryTree
{
public function addCategory(string $category, string $parent=null) : void
{
}
public function getChildren(string $parent) : array
{
return [];
}
}
$c = new CategoryTree;
$c->addCategory('A', null);
$c->addCategory('B', 'A');
$c->addCategory('C', 'A');
echo implode(',', $c->getChildren('A'));
结果应该是“B,C”或“C,B”。
【问题讨论】:
标签: php arrays function class object