Function Return Question
Posted: Tue Jun 01, 2010 12:26 am
The following line works just fine, but I want to put it in to a function:
I've got a ton of similar lines that need to do the same thing so I want to functionalize it. So far I have this:
The idea here is to use the field name as input for the function and have it return either the session data or the results of $clientinfo[]. It works for the session data, but I can't seem to get it to return the client data. It tells me that $clientinfo isn't set.
Thanks!
Code: Select all
if(isset($_SESSION['v_p_first_name'])) { echo $SESSION['v_p_first_name']; } else { echo $clientinfo['p_first_name'];Code: Select all
$_SESSION['v_p_first_name'] = "Jake";
$clientinfo['p_first_name'] = "Ben";
Function decide_data($input) {
$vinput = 'v_'.$input;
If (isset($_SESSION[$vinput])){
return $_SESSION[$vinput]; //this part works just fine.
}
Else {
return //$clientinfo['p_first_name'];
}
}
echo decide_data('p_first_name')
Thanks!