stijn0713 Posted June 20, 2012 Share Posted June 20, 2012 I call a method and i want to return more then one value. this can be done in several ways, i've seen some like $x = $a . "|" . $b . "|" . $c; return $x; and then using explode where you invoke the method. This trick worked for me untill i wanted to return 3 arrays. After exploding the arrays by |, i cannot use them anymore, e.g. i cannot f.e. print_r them. I will only display 'array'. I guess this has something to do with call by reference / call by value. Could somebody explain it more precisely ? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/264491-returning-multiple-arrays/ Share on other sites More sharing options...
trq Posted June 20, 2012 Share Posted June 20, 2012 Firstly, if your function needs to return more than one value your likely doing too much within the function. Anyway, just return the arrays within an array. return array($a, $b, $c); Quote Link to comment https://forums.phpfreaks.com/topic/264491-returning-multiple-arrays/#findComment-1355431 Share on other sites More sharing options...
stijn0713 Posted June 20, 2012 Author Share Posted June 20, 2012 oeps, ok thanks Quote Link to comment https://forums.phpfreaks.com/topic/264491-returning-multiple-arrays/#findComment-1355470 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.