johnwayne77 Posted February 12, 2009 Share Posted February 12, 2009 i have a function... my question is if i can have two returns at the end of it so i can use both value in my script Link to comment https://forums.phpfreaks.com/topic/145004-solved-functions-question/ Share on other sites More sharing options...
samshel Posted February 12, 2009 Share Posted February 12, 2009 you can return an array containing the 2 values... Link to comment https://forums.phpfreaks.com/topic/145004-solved-functions-question/#findComment-760868 Share on other sites More sharing options...
johnwayne77 Posted February 12, 2009 Author Share Posted February 12, 2009 how do i do that? i have : function f1($var) { .... $var1 = $someothervar; $var2 = $onemorevar; .... return $var1; return $var2; } i need to use $var1 and $var2 in the script ( i already use $var1 as following: foreach ($var1 as $scriptvar) { } Link to comment https://forums.phpfreaks.com/topic/145004-solved-functions-question/#findComment-760875 Share on other sites More sharing options...
samshel Posted February 12, 2009 Share Posted February 12, 2009 function f1($var) { .... $var1 = $someothervar; $var2 = $onemorevar; .... return array($var1,$var2); } $arrTemp = f1($var); $var1 = $arrTemp[0]; $var2 = $arrTemp[1]; //use $var1 and $var2 here on.. Link to comment https://forums.phpfreaks.com/topic/145004-solved-functions-question/#findComment-760880 Share on other sites More sharing options...
johnwayne77 Posted February 12, 2009 Author Share Posted February 12, 2009 thanks, i'll try that Link to comment https://forums.phpfreaks.com/topic/145004-solved-functions-question/#findComment-760883 Share on other sites More sharing options...
johnwayne77 Posted February 13, 2009 Author Share Posted February 13, 2009 it worked, cheers Link to comment https://forums.phpfreaks.com/topic/145004-solved-functions-question/#findComment-760958 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.