PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
//ASSUME FORM HAS BEEN POSTED
//START AN FOREACH LOOP TO READ ARRAY VALUES
foreach($_POST["chkSession"] as $chkValue)
{
$newArrayVar = $chkValue; //THIS IS THE LINE WHERE I WANT TO BE ABLE TO BASICALLY REPLICATE THE ARRAY($chkValue)
}
How would I assign the array values to the new variable as an array?
If i'm trying to add values to this array within a loop, how do I append the new array variable so that the new array holds more and more values throughout the loop?
//THIS IS THE NEW ARRAY DEFINITION
$sessionArray=array();
//THE BELOW CODE GETS THE VALUE FROM EACH RADIO ELEMENT THAT RELATES TO A SINGLE CATEGORY ID FROM A DB
$dbGetCatCount=mysql_query("SELECT DISTINCT intSessionDateTimeId FROM otblSessionDate") or die(mysql_error());
$dbCatCount=mysql_num_rows($dbGetCatCount);
while($row=mysql_fetch_array($dbGetCatCount))
{
extract($row);
if(isset($_POST["chk" . $row["intSessionDateTimeId"]]))
{
$sessionArray .= $_POST["chk" . $row["intSessionDateTimeId"]];
}
}
When I print $sessionArray to the screen it displays as: Array14
Basically I'd like to use ".=" so that the next value in the loop would append to the already existing $sessionArray. However, I know ".=" does not work with arrays.
The values will be dynamically generated so I will never know how many there will be.