bundyxc Posted July 30, 2009 Share Posted July 30, 2009 I want to have a function that creates an array, and I want to be able to pass that array out of the function, and onto the variable that the function has been assigned to. $var = array_maker() echo $var[1]; // This should echo the value of the first key of the array, inside of the function. This seems completely simple, but I can't figure it out. Thank you for your time, guys. Link to comment https://forums.phpfreaks.com/topic/168207-pass-array-to-function/ Share on other sites More sharing options...
lonewolf217 Posted July 30, 2009 Share Posted July 30, 2009 here's a basic example <?php $b = returnArray(); echo $b[1]; function returnArray() { $a = array("1","2","3"); return $a; } ?> Link to comment https://forums.phpfreaks.com/topic/168207-pass-array-to-function/#findComment-887191 Share on other sites More sharing options...
bundyxc Posted July 30, 2009 Author Share Posted July 30, 2009 Duh. I completely forgot about the return. :l Thanks lonewolf217. Link to comment https://forums.phpfreaks.com/topic/168207-pass-array-to-function/#findComment-887198 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.