$all_categories=get_cats($cat);
$headingPrinted = false;
$childCount = 0;
for($i=0;$i<sizeof($all_categories);$i++)
{
$arr=get_gender($cat);
if($arr[$i]=='0')
{
if (!$headingPrinted) {
echo "  "."Sons:";
$headingPrinted = true;
}
echo "  ".$all_categories[$i].",";
$childCount++;
}
}
if ($childCount >= 3) {
echo $childCount, $childCount == 1 ;
}
else {
// you may want to do something if none found
}
$headingPrinted = false;
$childCount = 0;
for($i=0;$i<sizeof($all_categories);$i++)
{
$arr=get_gender($cat);
if($arr[$i]=='1'){
if (!$headingPrinted) {
echo "  "."Daughters:";
$headingPrinted = true;
}
echo "  ".$all_categories[$i].",";
$childCount++;
}
}
if ($childCount >= 3) {
echo $childCount, $childCount == 1 ;
}
else {
// you may want to do something if none found
}
我正在显示&#34; Sons&#34;然后他们的名字,然后他们的计数和单词&#34;女儿&#34;那么他们的名字就算了。我想这样显示:
儿子:a,b,c,d:4;
女儿:p,q,r,s:4;
$all_categories
是一个数组,我可以在其中获取给定ID的所有子项,get_gender
和get_cats
是函数。
现在我正在显示:
a,b,c,d,:4;
我只想在以下情况下显示计数:
我想显示与上面相同的结果我说。提前致谢 有人试过这个......