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:


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


Also array_is_list is available as of PHP 8.1.

“REST” interfaces

I just wanted to get something that I’ve thought for many years on record, because I don’t think I’ve ever had the chance to discuss it much before, but I believe JSON web services (“REST APIs”) and web applications should deal only in two HTTP verbs, being: GET and POST. You use GET for queries and you use POST for submissions. All POST operations go through business logic for particular services and CRUDing URLs is a supremely bad idea, in my opinion. Just wanted to get that on record. Thanks. p.s for web applications you should 3xx on success, not 2xx on success; what you do for JSON web services is up to you, but for those 2xx is probably fine.