-4

I want to know if there's any difference in either the output or the object being created when these commands are run to create the object $array.

$array = ["Sagittarius", "Cancer", "Gemini", "Pisces"];

$array = array("Sagittarius", "Cancer", "Gemini", "Pisces");

Thanks for the feedback!!

Richard
  • 55
  • 1
  • 7
nedhaskins
  • 25
  • 5
  • 2
    no difference, 2nd one was original, 1st one was added later, around php 5 (or even4), but right now both are equal – Iłya Bursov Jun 10 '22 at 00:40
  • 1
    Nothing. They accomplish the same goal, and one is short syntax of the other. See [this info](https://www.php.net/manual/en/language.types.array.php#example-54), but the shorter syntax came later, as the previous comment mentions. – Paul T. Jun 10 '22 at 00:41
  • 1
    I just read somewhere, the shorter version came in PHP 5.4. – Aranxo Jun 10 '22 at 01:27
  • I don't think this should be a SO question. It's a simple search to do to get this info. If you really "want to know", try to search for it before asking a question here, you may find out other interesting stuff about PHP and writing code in general. – Cornel Raiu Jun 10 '22 at 04:22

1 Answers1

0

They are the same but [] is the shortened version introduced in PHP 5.4.0.

http://docs.php.net/manual/en/language.types.array.php

tim
  • 2,530
  • 3
  • 26
  • 45