I want to do something like this without using extra variables:
class className {
public static function func(){
return array('true','val2');
}
}
if(className::func()[0]) {
echo 'doğru';
} else {
echo 'Yanlış';
}
className::func()[0]
is called array dereferencing, and is not valid syntax in all PHP versions. It will be is available starting in PHP 5.4, currently in beta, released March 2012. For earlier PHP version, you will need to use an extra variable somewhere to store the array returned from className::func()
.
See the PHP 5.4 Array documentation for implementation details.
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