Im using an if statement to determine what to return in a function, but it seems to be not working the way i want it to.
function DoThis($dogs, $cats){
// do something with dogs, pet them perhaps.
$reg = $dogs[0];
$nate = $dogs[1];
if($cats = "dave"){return $reg;}
if($cats = "tom"){return $nate;}
}
$cats is a string (if that helps), and when entered it doesn't yield any return.
If i manually set a return, that works, but the above doesnt for some reason.
To test for equality, use the == (double equals) operator instead of the = (single equals) operator.
For example:
if("dave" == $cats){return $reg;}
if("tom" == $cats){return $nate;}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With