Arrays in PHP

Some notes about arrays in PHP over here: PHP: Frankenstein arrays. I was already aware of most of that but I thought the notes at the bottom about supporting JSON were handy:
If you want to enforce an array to encode to a JSON list (all array keys will be discarded), use:

json_encode(array_values($array));

And if you want to enforce an array to encode to a JSON object, use:

json_encode((object)$array);

Also array_is_list is available as of PHP 8.1.

Wide indexes or hashing

Today on 8.3.6 Multiple-Column Indexes I learned about the hash index technique:

SELECT * FROM tbl_name
  WHERE hash_col=MD5(CONCAT(val1,val2))
  AND col1=val1 AND col2=val2;

As they say: “As an alternative to a composite index, you can introduce a column that is “hashed” based on information from other columns. If this column is short, reasonably unique, and indexed, it might be faster than a “wide” index on many columns. In MySQL, it is very easy to use this extra column.”