From a function we can get back a set of variables by using an array. A function returns any variable to the main script by using return statement. Here we will try to return a set of variables by using an array. Our main script will receive the array and we will use while each statement to display all elements of an array.
We will change a script a bit and try to pass ( as input ) a string to the function. This string we will break by using split command and create an array. This array we will return to main script for displaying.
<?Php
function test($my_string){
// creating an array by split command
$my_array=split(" ",$my_string);
return $my_array; // returning the array
}
// sending a string to function as input //
$collect_array=test("Hello welcome to plus2net");
// displaying the elements of the collected array
while (list ($key, $val) = each ($collect_array)) {
echo "$key -> $val <br>";
}
?>
Tuesday, July 29, 2008
Returning an array of variables from PHP function
Subscribe to:
Post Comments (Atom)
3 comments:
iyprn6s-1wt9xsp-tw6q67b5-0 http://online-gambling-mo.lookera.net#1
auto insurance quotes
[url=http://urlser.com/?m6c0v#3]auto insurance[/url]
[url]http://best-online-casino-mo.lookera.net#4[/url]
[http://online-gambling-mo.lookera.net#5 online gambling]
"homeowners insurance":http://urlser.com/?aBCA5#6
[LINK http://urlser.com/?nm4rK#7]cheap auto insurance[/LINK]
[img]http://victor.freewebhostingpro.com/1.php[/img]
mqy8bsh-w9bia1e-tw6q67b5-0 http://best-online-casino-mo.lookera.net#1
progressive insurance
[url=http://urlser.com/?5Nnno#3]progressive insurance[/url]
[url]http://online-gambling-mo.lookera.net#4[/url]
[http://roulette-mo.lookera.net#5 roulette]
"best online casino":http://best-online-casino-mo.lookera.net#6
[LINK http://urlser.com/?e64r6#7]car insurance[/LINK]
[img]http://victor.freewebhostingpro.com/1.php[/img]
6xp3bld-at93815-tw6q67b5-0 http://online-gambling-mo.lookera.net#1
gambling
[url=http://urlser.com/?IQpnn#3]car insurance quotes[/url]
[url]http://urlser.com/?IQpnn#4[/url]
[http://black-jack-mo.lookera.net#5 black jack]
"gambling":http://gambling-mo.lookera.net#6
[LINK http://urlser.com/?e64r6#7]car insurance[/LINK]
[img]http://victor.freewebhostingpro.com/1.php[/img]
Post a Comment