I've search hard for this information and could not find it. After several hours of testing and learning more about regex, I have come up with the following search/replace that saves me hours of work updating outdated PHP files with deprecated each statements when used in combination with while as a substitute for foreach.
Looking for:
Find: while\(list\(([\$a-z0-9_]+),([\$[a-z0-9_]+)\) = each\(([\$a-z0-9_\[\]\"]+)\)\)
Replace: foreach(\3 as \1=>\2)
Be sure to use regular expression engine Unix or Perl for this search/replace.
*note - this will include array variables used in the each
Looking for:
Code: Select all
while(list($key,$val) = each($values))
while(list($key1,$val1) = each($arrVals["name"]))
Replace: foreach(\3 as \1=>\2)
Be sure to use regular expression engine Unix or Perl for this search/replace.
*note - this will include array variables used in the each