function isChongHao(ary,i,j)
if ary(i-1,j)<>0 or ary(i+1,j) then
isChongHao=true
exit function
end if
isChongHao=false
end function
views:
50answers:
3
+3
A:
function isChongHao($ary, $i, $j) {
if($ary($i-1, $j) != 0 || $ary($i+1, $j)) {
return true;
}
return false;
}
I suppose $ary contains a name of a function.
Palantir
2009-11-10 09:34:16
A:
Assuming ary is an array
function isChongHao($ary,$i,$j) {
return (($ary[$i-1][$j] || $ary[$i+1][$j]) ? true : false);
}
Assuming ary is a function
function isChongHao($ary,$i,$j) {
return (($ary($i-1,$j) || $ary($i+1,$j)) ? true : false);
}
Peter Lindqvist
2009-11-10 09:44:21
+1
A:
function isChongHao($ary, $i, $j)
{
return ($ary[$i-1][$j] || $ary[$i+1][$j]);
}
You should probably check to ensure those indexes are set in the array beforehand, though, with an isset() call.
Chris
2009-11-10 09:51:22