PHP code for function returning more than one value, PHP code for function returning array values.
Code :
<?php
function return_arrayvalues() {
$Fname = "Fname";
$Lname = "Lname";
$Mname = "Mname";
$Age = "20";
return array ($Fname, $Mname, $Lname, $Age);
}
list ($FN, $MN, $LN, $Ag) = return_arrayvalues();
echo "Name : ".$FN." ".$MN." ".$LN." <br>Age : ".$Ag."<br>";
?>
Output :
Name : Fname Mname Lname
Age : 20
Code :
<?php
function return_arrayvalues() {
$Fname = "Fname";
$Lname = "Lname";
$Mname = "Mname";
$Age = "20";
return array ($Fname, $Mname, $Lname, $Age);
}
list ($FN, $MN, $LN, $Ag) = return_arrayvalues();
echo "Name : ".$FN." ".$MN." ".$LN." <br>Age : ".$Ag."<br>";
?>
Output :
Name : Fname Mname Lname
Age : 20
Comments