Adding values into an array HELP HELP

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!

Moderator: General Moderators

Post Reply
stantheman
Forum Commoner
Posts: 38
Joined: Wed May 26, 2004 8:57 am

Adding values into an array HELP HELP

Post by stantheman »

I want to be able to had values to an array one value at a time instead of all at once

here is an example of what i want to do
if check box is checked
{
array(1=>"True")
}
else
{
}

if checkbox2 is checked
{
array(2=>"True")
}
else
{
}

if is doesn't get checked i do not want to add anything to the array i only want to add things to the array if it is checked.
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

Code: Select all

$your_arrayї1] = 'True'
etc. etc.
stantheman
Forum Commoner
Posts: 38
Joined: Wed May 26, 2004 8:57 am

Post by stantheman »

ok so wqould the could look something like this

$arraytest = array()

$arraytest[1]='True'

then to print i do this right
echo $arraytest[1]
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

the first item in an array would be targetted by $var[0];


the second $var[1]; and etc
Post Reply