edd12345678 Posted December 14, 2011 Share Posted December 14, 2011 Hi Guys, I am having a small problem with an array. I want to push information from a form into an array. However each time I do it it just replaces the last entry in the array with the information in stead of adding a new value to the array. <?php // if generate is pressed if(isset($_POST['generate'])){ // get values from form $name = htmlspecialchars($_REQUEST['add']); array_push($stack, $name); print_r($stack); } ?> Can anybody help? Thanks Ed Quote Link to comment https://forums.phpfreaks.com/topic/253169-session-array-push/ Share on other sites More sharing options...
Pikachu2000 Posted December 14, 2011 Share Posted December 14, 2011 Every time the form is submitted the script runs again. Variables aren't persistent across multiple submissions. Quote Link to comment https://forums.phpfreaks.com/topic/253169-session-array-push/#findComment-1297898 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.