函数数组定义?

I have a slight gap in my understanding of how functions and arrays work together

I have this function which gets the login info from a form named submittedlogin then performs a simple query and fetches the array if the, but only if the values arent empty and returns errors if there are (truncated that part)

function check_login($dbc, $email = '', $pass = '') {

$q = "SELECT user_id, user_type, first_name, time_zone FROM users WHERE email='$e' AND pass=SHA1('$p')";

Then on the actual login page I call the function with the posted values

if (isset($_POST['submittedlogin'])) {

    require_once ('includes/login_functions.inc.php');
    require_once ('../mysqli_connect.php');
    list ($check, $data) = check_login($dbc, $_POST['email'], $_POST['pass']);

    if ($check) { // OK!

        // Set the session data:.
        session_start();
        $_SESSION['user_id'] = $data['user_id'];
        $_SESSION['first_name'] = $data['first_name'];
        // Get priviledges
        $_SESSION['user_type'] = $data['user_type'];
        // Store the HTTP_USER_AGENT:
        $_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']);
        //

Note that the $_SESSION['user_type'] = $data['user_type']; does return the correct value.

My question would be how is how does the syntax work here? :

list ($check, $data) = check_login($dbc, $_POST['email'], $_POST['pass']);

Better phrasing would probably be, how are the $check and $data variables defined?? Does:

$check = check_login($dbc) and $data = $q??

Clarification would be much appreciated.

list($val1, $val2) = array('val1', 'val2');

now $val1 is 'val1'; and $val2 is 'val2'

list($val1, $val2) = array('val1', 'val2', 'val3', 'val4');

we've got 2 first values from array (nothing changed to $val1 and $val2).

So, if you do something like

$sql = 'SELECT if(md5(\''.$Password.'\') = password,1,0), username, email FROM users WHERE username = \''.$username.'\'';
$res = mysql_query($sql, $connection);
list($isAuthorized, $username, $email) = mysql_fetch_array($res);

You'd get array of 3 element returned by mysql_fetch_array and pass them into $isAuthorized, $username and $email variables.

Im not sure you can use the list trick with the return from a function but i could be mistaken... Regardless in order to do that you would ned to return an array from function. the vars you give to list are the array elements on the right side of the equation so :

list($check, $data) = array('one', 'two');
echo $check; // outputs one
echo $data; // outputs two

the function check_login returns an array like this:

array('user', 'type', 'first', 'time');

and by

list ($check, $data) =  array('user', 'type', 'first', 'time');

$check and $data gets equal to the first two values from the array

it means the function check_login() return an array having two values and each will be assigned to the variable in the list()

let u get return value from check_login() is

array('yes','hello');

and using list ($check, $data) = check_login($dbc, $_POST['email'], $_POST['pass']);

means

$check = 'yes';
$data =''hello';

Reference