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? Link to comment https://forums.phpfreaks.com/topic/96607-returning-multiple-values-from-a-function/ 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. Link to comment https://forums.phpfreaks.com/topic/96607-returning-multiple-values-from-a-function/#findComment-494370 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; } Link to comment https://forums.phpfreaks.com/topic/96607-returning-multiple-values-from-a-function/#findComment-494371 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? Link to comment https://forums.phpfreaks.com/topic/96607-returning-multiple-values-from-a-function/#findComment-494374 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 Link to comment https://forums.phpfreaks.com/topic/96607-returning-multiple-values-from-a-function/#findComment-494382 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.