From 8c47ccfab90d855b63e63c028ebf730c15f1f978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Grasl?= Date: Thu, 2 Jun 2016 13:49:42 +0200 Subject: [PATCH] kill tabs from code add space kill tabs from code add space and normalize the code :D --- tabs_to_space.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tabs_to_space.php diff --git a/tabs_to_space.php b/tabs_to_space.php new file mode 100644 index 0000000..6d2f4ce --- /dev/null +++ b/tabs_to_space.php @@ -0,0 +1,34 @@ +_connection = $connection; + } +}'; + +$result = ''; +foreach (token_get_all($string) as $token) { + if (is_array($token) && in_array($token[0], [T_ENCAPSED_AND_WHITESPACE, T_CONSTANT_ENCAPSED_STRING])) { + $token[1] = preg_replace('#\s#', '.', $token[1]); + } + $result .= is_array($token) ? $token[1] : $token; +} +$string = $result; + +if((bool) preg_match('~\x{00a0}~siu', $string)) { #remove super stupid space! + $text = preg_replace('~\x{00a0}~siu', ' ', $string); +} +$string = str_replace("\n", PHP_EOL, str_replace(["\r\n", "\r"], "\n", $string)); #newline characters normalizer for the current OS +$new = trim(preg_replace('/\t+/', ' ', $string)); +echo '
';
+var_dump($new);