4

One of not many things I really hate about PHP is when I have to write arrays. They so sugary, it is very shitty experience. I just hope we can get JSON style arrays some day.

Comments
  • 5
    if you dont like arrays, create objects instead.
  • 4
    @C0D4 if you don't like objects, create individual variables instead
  • 1
    @alexbrooklyn i like my array() though.
  • 1
    Before we got short array syntax, I would have agreed. But I think it's at least ok now.
  • 1
    What do you not like about them? I think they are really "JSON like" already.

    array(
    "test" => 1337,
    "sub_array" => array()
    );
    is pretty nice.
  • 2
    @PrivateGER If you use [], not array(), the only difference is => instead of :
  • 1
    No it's not. Arrays can not contain key value pairs. You need an object for that. Arrays are indexed by sequential numbers in almost all languages.
  • 1
    My beef is not with arrays but with objects that can not be initialized like in JSON. That makes people use arrays where the syntax of an object is nicer. (I know one can convert an array but that is way to much overhead).
  • 3
    @hjk101 welcome to php where I can do anything I please.
Add Comment