Hacker News new | ask | show | jobs
by FriedrichN 1670 days ago
My absolute favorite thing about PHP is the arrays and the ease of working with them. Whenever I find myself working in another language dealing with loads of data I'm immediately thinking of how easy it would be to accomplish it in PHP.

And I've been loving all the new additions to PHP over the last few years as well. Version 5 was rather limited but since 7 it has grown into an actual programming language for which I feel I don't have to apologize for.

1 comments

Is it really useful to have ordered map as the "only" collection type?

I guess it might be Stockholm syndrome - but I'm quite comfortable with a "list/array" type (numeric keys, ordered) and a "map/hash_map" type (objects as keys).

Especially give that with phps "power" you can:

  $array = array(
    1    => "a",
    "1"  => "b",
    1.5  => "c",
    true => "d",
  );
  var_dump($array);
Ouputs:

  array(1) {
    [1]=>
    string(1) "d"
  }
https://www.php.net/manual/en/language.types.array.php
That's indeed a case where it fails, but in all my years I have maybe ran into that problem once. But it's trivial to implement a more strict form of array if you wish. And if I remember correctly there are some standard extensions that have classes to do just that.

And for the record, it's not Stockholm syndrome, I use plenty of other languages and I know the benefits and drawbacks of each of those.