tags:

views:

50

answers:

3
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
+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
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
+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