Bennovations Knowledgebase
Search:     Advanced search
Browse by category:
Contact Us

How to Return more than one value from a PHP array

Views: 353
Votes: 0
Posted: 09 Apr, 2009
by: Patridge B.
Updated: 09 Apr, 2009
by: Patridge B.
Easy Example how to return more than one value from a PHP array without using a  loop to extract the values:

===================================================
<?php

function getFruit ($var1,$var2) {
$var1="Apple";
$var2="Banana";
 return array($var1,$var2);;
}


list($fruit1,$fruit2)=getFruit("steak","chicken");

echo "$fruit1<BR>$fruit2";

?>


===================================================

Results:

Apple
Banana

Others in this Category
document Assigning a variable to a variable within a loop using PHP
document View Day of the week based on date
document Nested Variable assignments within PHP - Calling a variable with a variable inside a FOR loop
document Multi-dimensional PHP Arrays
document Function to make all http prefixed URLs in text output hyperlinks
document Populating an array inside of a for loop using PHP
document Select MAX Value from MySQL Database using PHP
document PHP Function to display the current day and date based on timezone



RSS