#!/usr/bin/php //Downloaded from http://shadsplace.org/beautify-php/beautify.phps =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 $str=preg_replace("/}\s*else\s*/m", "} 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); // remove line breaks between condition and brace, // set one space between control keyword and condition $str=preg_replace("/(if|for|while|switch)\s*(\([^{]+\))\s*{/i", "\\1 \\2 {", $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