OldWest Posted November 13, 2010 Share Posted November 13, 2010 I've got a few hours in this, read the manual on return (and it appears my print_r should be working!).. And I am unable to get print_r() to output the contents of my function array. What am I doing wrong? function getStateName() { $stateName = array("Alabama","Florida","Nevada"); return $stateName; } echo "<pre>"; echo print_r($stateName); echo "</pre>"; Link to comment https://forums.phpfreaks.com/topic/218547-print_r-array-from-function-cannot-get-an-print_r-to-output/ Share on other sites More sharing options...
Vitamin Posted November 13, 2010 Share Posted November 13, 2010 You have to call getStateName() first function getStateName() { $stateName = array("Alabama","Florida","Nevada"); return $stateName; } echo "<pre>"; $test = getStateName(); echo print_r($test); echo "</pre>"; Link to comment https://forums.phpfreaks.com/topic/218547-print_r-array-from-function-cannot-get-an-print_r-to-output/#findComment-1133723 Share on other sites More sharing options...
OldWest Posted November 13, 2010 Author Share Posted November 13, 2010 Vitamin, Thanks for confirming that .. I tried that earlier, and it was not working BUT I just found the problem was in my form.. I forgot to set the method to post, and I could not get anything to print to the screen with my submit button! I think its time for bed. Link to comment https://forums.phpfreaks.com/topic/218547-print_r-array-from-function-cannot-get-an-print_r-to-output/#findComment-1133724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.