tags:

views:

36

answers:

2

How do I make it so every array is set to false .. I don't want to do it like this:

$a = array('clue1' => 'false', 'clue2' => 'false', 'clue3' => 'false');

because that will take long time. Is there easier way?

+2  A: 

http://www.php.net/manual/en/function.array-fill.php array_fill may be of use.

Paul
+1  A: 

I think he is looking for array_fill_keys

$keys = array("clue1", "clue2", "clue3", "clue4");
$a = array_fill_keys($keys, "false");
print_r($a);

Of course you could use a for statement to setup the clue part too.

for ($x=1; $x < 5; $x++) {
    $keys[] = "clue".$x;
}
//$keys = array("clue1", "clue2", "clue3", "clue4");
$a = array_fill_keys($keys, "false");
print_r($a);
Jared