snipt

Ctrl+h for KB shortcuts

Text only

PHP Find & Replace, to fix unquoted array indexes [key] => ['key']

1
2
3
4
5
regex:
(\[)[a-zA-Z0-9\-]*(\])

replace:
['$2']
https://snipt.net/embed/0b09676f104e19d27e02faedb04e3464/
/raw/0b09676f104e19d27e02faedb04e3464/
0b09676f104e19d27e02faedb04e3464
text
Text only
6
2019-06-23T21:58:05
True
False
False
/api/public/snipt/7007/
php-find-replace-to-fix-unquoted-array-indexes-key-key
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>regex: </span><span id="L-2"><a name="L-2"></a>(\[)[a-zA-Z0-9\-]*(\]) </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>replace: </span><span id="L-5"><a name="L-5"></a>[&#39;$2&#39;] </span></pre></div> </td></tr></table>
php, regex