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 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); 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 Link to comment https://forums.phpfreaks.com/topic/264491-returning-multiple-arrays/#findComment-1355470 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.