Python provides a neat way for functions to return multiple arguments via "tuple unpacking". For example:
def blah:
return ('one', 'two')
rval_1, rval_2 = blah()The same can be done in PHP relatively easily via the list construct:
function blah()
{
return array('one', 'two');
}
list($rval_1, $rval_2) = blah();These other articles I've written may be interesting to you as well:
Comments
PHP vs Python
Why not just use Python :(
Unfortunately, this was part
Unfortunately, this was part of a larger application written in PHP. Why would anyone use PHP if they weren't stuck with it?
It's really sort of funky that I apply Python idioms to PHP and Java. I like to think my code is more concise and makes sense to me, but less so to people who only do PHP or Java and not Python... how many times do you see people using PHP's list construct?