Answers for "php return multiple variables from function"

PHP
0

php function return multiple values

// Function to swap two numbers 
function swap( $x, $y ) {  
    return array( $y, $x ); 
}
Posted by: Guest on October-01-2020
0

php return multiple variables from function

<?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();

?>
Posted by: Guest on January-24-2022

Code answers related to "php return multiple variables from function"

Browse Popular Code Answers by Language