Paypal
Paypal

Reputation: 361

How to convert the ASP code snippet to PHP?

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 

Upvotes: 1

Views: 109

Answers (3)

Palantir
Palantir

Reputation: 24182

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.--

Ooops, strike that: Joel thanks, I totally missed the fact that it was vbscript!!! O.o Now maybe it is better...

Upvotes: 4

Peter Lindqvist
Peter Lindqvist

Reputation: 10200

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);
}

Upvotes: 0

Chris
Chris

Reputation: 758

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.

Upvotes: 1

Related Questions