Answers for "php function return multiple values"

PHP
6

return two variables php

function getXYZ()
{
    return array(4,5,6);
}

list($x,$y,$z) = getXYZ();

// Afterwards: $x == 4 && $y == 5 && $z == 6
// (This will hold for all samples unless otherwise noted)
Posted by: Guest on September-17-2020
2

php return array

<?php

function data() {
    $out[0] = "abc";
    $out[1] = "def";
    $out[2] = "ghi";
    return $out;
}

$data = data();
foreach($data as $items){
    echo $items;
}
Posted by: Guest on May-23-2020
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

Code answers related to "php function return multiple values"

Browse Popular Code Answers by Language