Skip to content

Instantly share code, notes, and snippets.

@nelsonsar
Created July 6, 2013 19:09
Show Gist options
  • Save nelsonsar/5940906 to your computer and use it in GitHub Desktop.
Save nelsonsar/5940906 to your computer and use it in GitHub Desktop.
PHP tuples. With PHP we can make Python tuples using an array and the list function, this is not built-in, but it's a way to make code more readable!
<?php
function return_fake_tuples()
{
return array(
'apple', 'banana'
);
}
list($apple, $banana) = return_fake_tuples();
@tbreuss
Copy link

tbreuss commented Apr 26, 2023

Because your gist ranks high on Google while not being up-to-date, I've created one, that is representing tuples using short array syntax and [] destructuring. See: https://gist.github.com/tbreuss/17b94b8bd74124ff75039a2b03a380c0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment