Stephen68 Posted May 27, 2009 Share Posted May 27, 2009 Sorry to bug you guys for this but I must be having mind freeze today I'm looping through an $_POST[] value and I'm trying to add it to an array. There is some code at the first of this that tells me how many of the value there are that I get from a hidden form value. Anway this is the code I'm using to get the values into an array. <?php for ($i = 1; $i <= $numAnimal; $i++) { $arrayAnimal[] = $_POST['animal_$i']; } ?> Ok what I'm trying to store in the array if the value of $_POST['animal_1'] The above does loop but it stores an empty value, any help would be great. Stephen Link to comment https://forums.phpfreaks.com/topic/159869-solved-simple-but-cant-get-it/ Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 What is the value of $_POST['animal_1']? Link to comment https://forums.phpfreaks.com/topic/159869-solved-simple-but-cant-get-it/#findComment-843144 Share on other sites More sharing options...
Stephen68 Posted May 27, 2009 Author Share Posted May 27, 2009 The value is 8 Here is what I did that works, if there is something wrong with doing this way please let me know <?php for ($i = 1; $i <= $numAnimal; $i++) { $arrayAnimal[] = $_POST['animal_'.$i]; } ?> Thanks Link to comment https://forums.phpfreaks.com/topic/159869-solved-simple-but-cant-get-it/#findComment-843146 Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 Ah, stupid me. Variable interpolation doesn't work with single quotes. I missed that. Sorry. Link to comment https://forums.phpfreaks.com/topic/159869-solved-simple-but-cant-get-it/#findComment-843159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.