Member Avatar
napninjanx

Which of the following correctly sets up a PHP array??

  1. array() = $array_values[];

  2. $array_values = array();

  3. array() = $array_values[];

  4. $array_values = new array();

Member Avatar
napninjanx

I think It's 2 right?

$array = array();

you don't need to declare before hand either you can use:

$array[] = $value;//add to end
$array[2] = $value;//add/overwrite entry with key of 2

1, 3 and 4 are wrong in php, 4 is the javascript to declare an array and 2 is correct

yeap...2 is correct.

Member Avatar
napninjanx

Thanks for the info.