@anonymous/

RequiredColorlessUnits

PHP (Legacy)

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.7540894184216245","path":"main.php","file":{"path":"main.php","content":{"asEncoding":{"base64":"PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCd1dGYtOCcpOwogCiR0ZXh0ID0gItC90YMg0YfRgtC+LiAgICAgINC90LUg0YHQvNC+0YLRgNC10Lsg0LXRidC1IGJsYWNrIG1lc2Eu0Y8g0YHQvtCx0LjRgNCw0LvRgdGPINGB0LrQsNGH0LDRgtGMICAs0L3QviDQstGB0LUg0LrQsNC6LdGC0L4g0L3QtdC60L7Qs9C00LAg0LHRi9C70L4uIjsKLy8g0JTQu9GPINGC0LXRgdGC0L7QsgovLyAkdGV4dCA9ICdyb3NlcyBhcmUgcmVkLGFuZCB2aW9sZXRzIGFyZSBibHVlLndoYXRldmVyIHlvdSBkbyBpJ2xsIGtlZXAgaXQgZm9yIHlvdS4nOwovLyAkdGV4dCA9ICfQv9GA0LjQstC10YIu0LXRgdGC0YwgMiDRhNGD0L3QutGG0LjQuCxwcmVnX3NwbGl0INC4IGV4cGxvZGUgLNC90LUg0L/QvtC90LjQvNCw0Y4s0LIg0YfQtdC8INC80LXQttC00YMg0L3QuNC80Lgg0YDQsNC30L3QuNGG0LAuJzsKIAovKiDQlNC10LvQsNC10YIg0L/QtdGA0LLRg9GOINCx0YPQutCy0YMg0LIg0YHRgtGA0L7QutC1INC30LDQs9C70LDQstC90L7QuSAqLwpmdW5jdGlvbiBtYWtlRmlyc3RMZXR0ZXJVcHBlcmNhc2UoJHRleHQpIHsKCSR0ZXh0ID0gdHJpbSgkdGV4dCk7CglyZXR1cm4gbWJfc3RydG91cHBlcihtYl9zdWJzdHIoJHRleHQsIDAsIDEpKSAuIG1iX3N1YnN0cigkdGV4dCwgMSk7Cn0KIAovKiDQuNGB0L/RgNCw0LLQu9GP0LXRgiDRgtC10LrRgdGCICovCmZ1bmN0aW9uIGZpeFRleHQoJHRleHQpIHsKCSRyZXN1bHQgPSAnJzsKCSRyZXN1bHQgPSBwcmVnX3JlcGxhY2UoJy8oXHcpKFxzKikoLHxcLnw7fDp8XD98ISkoXHMqKShcdykvdWknLCAnJDEkMyAkNScsICR0ZXh0KTsKCXJldHVybiAkcmVzdWx0Owp9CiAKJHN0cmluZ3MgPSBwcmVnX3NwbGl0KCcvKD88PVwuKD8hXC4pKS91JywgJHRleHQsIC0xLCBQUkVHX1NQTElUX05PX0VNUFRZKTsKJGZpeGVkU3RyaW5ncyA9IFtdOwoKZm9yZWFjaCAoJHN0cmluZ3MgYXMgJHN0cmluZykgewoJJGZpeGVkU3RyaW5nc1tdID0gbWFrZUZpcnN0TGV0dGVyVXBwZXJjYXNlKCRzdHJpbmcpOwp9CgokdGV4dCA9IGltcGxvZGUoIiAiLCAkZml4ZWRTdHJpbmdzKTsKJHJlc3VsdCA9IGZpeFRleHQoJHRleHQpOwplY2hvICJ7JHJlc3VsdH1cbiI7Cgo/Pg=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

error_reporting(-1);
mb_internal_encoding('utf-8');
 
$text = "ну что.      не смотрел еще black mesa.я собирался скачать  ,но все как-то некогда было.";
// Для тестов
// $text = 'roses are red,and violets are blue.whatever you do i'll keep it for you.';
// $text = 'привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница.';
 
/* Делает первую букву в строке заглавной */
function makeFirstLetterUppercase($text) {
	$text = trim($text);
	return mb_strtoupper(mb_substr($text, 0, 1)) . mb_substr($text, 1);
}
 
/* исправляет текст */
function fixText($text) {
	$result = '';
	$result = preg_replace('/(\w)(\s*)(,|\.|;|:|\?|!)(\s*)(\w)/ui', '$1$3 $5', $text);
	return $result;
}
 
$strings = preg_split('/(?<=\.(?!\.))/u', $text, -1, PREG_SPLIT_NO_EMPTY);
$fixedStrings = [];

foreach ($strings as $string) {
	$fixedStrings[] = makeFirstLetterUppercase($string);
}

$text = implode(" ", $fixedStrings);
$result = fixText($text);
echo "{$result}\n";

?>
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7