Returning multiple value from a function

Returning multiple value from a function

Usually Function returns a single return value to the caller. But in some case we need more than one value to be returned for our convenience.
This can be achieved by
1. Return value as an array
2. Concating the value in a string and splitting.

<?php
function user_process() {
$value[][’name’] = “First name”;
$value[][’age’] = 23;
$value[][’sex’] = ‘male’;
return $value;
}

$user = user_process();

echo “Name: “.$value[0][’name’].”, Age:”.$value[0][’age’].”, Sex:”.$value[0][’name’];

?>

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.