What is the meaning of [] [closed]

[] means push – put the given argument as a new element on the end of the array. That means that $ACTIVITYGROUPS is an array*.

$arr = array();
$arr[] = 1;       // Put 1 in position 0
$arr[] = "a";     // Put "a" in position 1
$arr[] = array()  // Put a new, empty array in position 2

As stated by the PHP docs, array_push has the same effect as [].


* If it’s not an array, using [] will give you a syntax error:

Warning: Cannot use a scalar value as an array in test.php on line 4

Leave a Comment