0

in evey tutorial they said you should make an array with "array()" but I realize that I can also make it with "[]" what are the difference?

array() :

$a = array("red","blue","green");

[] :

$a = ["red","blue","green"];
4
  • 3
    The differences are the versions of PHP. It's in the manual. php.net/manual/en/language.types.array.php Commented Jan 12, 2020 at 16:23
  • Although the duplicate talks about empty arrays - the principle (IMHO) is still the same. Commented Jan 12, 2020 at 16:24
  • 1
    @NigelRen They are basically the same, given the versions of PHP though. I added another dupe under the one you chose. Commented Jan 12, 2020 at 16:25
  • @NigelRen Yes, that ought to cover all the bases :) Commented Jan 12, 2020 at 16:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.