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 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. Link to comment https://forums.phpfreaks.com/topic/253169-session-array-push/#findComment-1297898 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.