After the last update of our php version we got a warning. This warning was that caused because we did not use quotation marks when specifying the associative array keys. For example, we wrote $section[title] instead of $section[‘title’] .
I solved this problem by simply search and replace. You can also apply this method to projects , if your editor supports a regex search and replace.
I use the atom editor and would recommend this editor as well. If you disagree, please write me.
In your search, you should enter the above snippet. Please make sure that the regex search is activated. It is searched for the following:
- Dollar sign
- Square bracket on
- Letters, numbers and underscores
- Square bracket close
The search stores the variable name and the associative array key for reuse.
The string that we enter when replacing is much easier to understand. The array is rebuilt, but this time quotes are used when specifying the key. The snippet looks like this:
This solution has already helped me on several projects and thanks to the REGEX search I have saved a lot of time. The problem was that specifying non-quoted array keys would appear to be a constant.