La fonction PHP renvoie plusieurs valeurs
// Function to swap two numbers
function swap( $x, $y ) {
return array( $y, $x );
}
Homely Hamerkop
// Function to swap two numbers
function swap( $x, $y ) {
return array( $y, $x );
}
<?php
function small_numbers()
{
return [0, 1, 2];
}
// Array destructuring will collect each member of the array individually
[$zero, $one, $two] = small_numbers();
// Prior to 7.1.0, the only equivalent alternative is using list() construct
list($zero, $one, $two) = small_numbers();
?>