Why, PHP, Why?
In this particular PHP site I’m working on, some past developer really liked to use bare strings for array indices. Here’s what I used to fix (most of) the unquoted strings:
sed -i -e "s/\$\(\w\+\)\[\([a-z]\w\+\)\]/$\1['\2']/gi" *.php
One downside of this one-liner is that real PHP constants are incorrectly quoted when used as array indices. Another is that multi-dimensional array indexing isn’t fixed correctly past the first dimension. My site wasn’t affected by either case, but YMMV.
Here’s to quick 90% solutions!