=0;$i--){ $placeholders[$i]="/".$placeholders[$i]."/"; } if ($placeholders){ $str=preg_replace($placeholders, $matches[0], $str); } return $str; } function privateParseString($str) { // inserting missing braces (does only match up to 2 nested parenthesis) $str=preg_replace("/(if|for|while|switch)\s*(\([^()]*(\([^()]*\)[^()]*)*\))([^{;]*;)/i", "\\1 \\2 {\\4\n}", $str); // missing braces for else statements $str=preg_replace("/(else)\s*([^{;]*;)/i", "\\1 {\\2\n}", $str); // line break check $str=preg_replace("/([;{}]|case\s[^:]+:)\n?/i", "\\1\n", $str); $str=preg_replace("/^function\s+([^\n]+){/mi", "function \\1\n{", $str); // remove inserted line breaks at else and for statements (no!) $str=preg_replace("/}\s*else\s*/m", "}\n else ", $str); $str=preg_replace("/(for\s*\()([^;]+;)(\s*)([^;]+;)(\s*)/mi", "\\1\\2 \\4 ", $str); // remove spaces between function call and parenthesis and start of argument list $str=preg_replace("/(\w+)\s*\(\s*/", "\\1(", $str); // adds line breaks between condition and brace // set one space between control keyword and condition $str=preg_replace("/(if|for|while|switch|elseif|else if|foreach)\s*(\([^{]+\))\s*{/i", "\\1 \\2 \n{", $str); // same for else $str=preg_replace("/(else)\s*{/i", "\\1 \n{", $str); // string keys in arrays: put them into quotes $str=preg_replace("/\[([\w][a-z0-9_][\w]*)\]/", "['\\1']", $str); // replace HTTP_.._VARS with newer equivalents $str = str_replace('HTTP_GET_VARS','_GET',$str); $str = str_replace('HTTP_POST_VARS','_POST',$str); $str = str_replace('HTTP_COOKIE_VARS','_COOKIE',$str); $str = str_replace('HTTP_SESSION_VARS','_SESSION',$str); return $str; } function privateIndentParsedString($str, $indent) { $count = substr_count($str, '}')-substr_count($str, '{'); if ($count<0){ $count = 0; } $strarray=explode("\n", $str); for($i=0;$i