I just found out about the short tags for arrays in PHP.
in my code I use :
$arr = array();
// do something
Now I can use :
$arr = []
So what's the benefit of using [] over array() in PHP?
there is no difference between []
and array()
, these both declarations are literally called as array declarations itself. the benefit here is you save some time while typing array
(5), while you can do it as []
(2).