<?php $re = '/\$\w+\K(?|\h*(\[)\h*(\'[^\']+\')\h*|(\h*\[)\h*("[^"]+")\h*)(?=])/m'; $str = '$foo [ "bar" ], $foo ["bar" ], $foo [ "bar"] $foo [ \'bar\' ], $foo [\'bar\' ], $foo [ \'bar\'] $foo [ \'this is different\' ]'; $result = preg_replace($re, '$1$2', $str); echo $result;
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`