Returning two values from a function

Return an array or an object if you need to return multiple values. For example:

function foo() {
    return array(3, 'joe');
}

$data = foo();
$id = $data[0];
$username = $data[1];

// or:
list($id, $username) = foo();

You can only return one value. But you can use an array that itself contains the other two values:

return array($uid, $sid);

Then you access the values like:

$ids = ids();
echo $ids[0];  // uid
echo $ids[1];  // sid

You could also use an associative array:

return array('uid' => $uid, 'sid' => $sid);

And accessing it:

$ids = ids();
echo $ids['uid'];
echo $ids['sid'];

function ids($uid = 0, $sid = '') 
{ 
    $uid = 1; 
    $sid = md5(time()); 

    return array('uid' => $uid,
                 'sid' => $sid
                );     
} 

$t = ids(); 
echo $t['uid'],'<br />';
echo $t['sid'],'<br />';

You can use an array and the list function to get the info easily :

function multi($a,$b) {
   return array($a,$b);
}

list($first,$second) = multi(1,2);

I hope this will help you

Jerome