Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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)
Comment

php return multiple values

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

?>
Comment

php function return multiple values

// Function to swap two numbers 
function swap( $x, $y ) {  
    return array( $y, $x ); 
}  
Comment

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

?>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel controller middleware example 
Php :: laravel has many limit 
Php :: get array value in php 
Php :: PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting 
Php :: compare two datetime php 
Php :: ErrorException symlink(): No such file or directory 
Php :: get romawi number php 
Php :: curl download progress bar php 
Php :: how to rename a table element in laravel 
Php :: add floater to open a modal in wordpress 
Php :: htaccess new date timestamp 
Php :: append variable into string php 
Php :: laravel migrate error default character 199 boot 
Php :: php return associative array 
Php :: REFERRER CODEIGNITER 3 
Php :: Skip model accessor laravel8 
Php :: Schema::defaultStringLength(199); 
Php :: acf get all choices from select 
Php :: include navbar or part in layout in laravel blade template 
Php :: laravel list all tbales 
Php :: static variable php 
Php :: custom validation in laravel 
Php :: cakephp group by count 
Php :: dump all variable in view codeigniter 
Php :: laravel check if model has relation 
Php :: sometimes validation in laravel 
Php :: php show hide td 
Php :: laravel collection pop 
Php :: how get some parameter from request in laravel 
Php :: xdebug phpstorm 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =