dmccabe Posted March 17, 2008 Share Posted March 17, 2008 I am just playing with my first function and want to use it to return information about the logged in user from our ldap server. I have all the ldap stuff working, but want to ask if it is possible to return multiple values from a function? so something like: function ldapvals($username,$password) { code stuff here return $memberof; return $profilepath; return $fullname; } is that possible? Quote Link to comment Share on other sites More sharing options...
trq Posted March 17, 2008 Share Posted March 17, 2008 Returning an array is as close as you'll get. Quote Link to comment Share on other sites More sharing options...
papaface Posted March 17, 2008 Share Posted March 17, 2008 Returning it in an array is function ldapvals($username,$password) { code stuff here $array = array(); $array[] = $memberof; $array[] = $profilepath; $array[] = $fullname; return $array; } Quote Link to comment Share on other sites More sharing options...
dmccabe Posted March 17, 2008 Author Share Posted March 17, 2008 THanks gents, excuse my ignorance, but how do I then pull the values from the array? Quote Link to comment Share on other sites More sharing options...
papaface Posted March 17, 2008 Share Posted March 17, 2008 $boo = ldapvals("fdfd","ff"); foreach ($boo as $ahhh => $eeee) { echo $eeee . " = > " . $ahhh . "<br />"; } Thats how I would do it anyway. or: $boo = ldapvals("fdfd","ff"); $boo[0];//element 1 $boo[1];//element 2 $boo[2];//element 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.