<?php $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 fixText($text) { $regexp = "/(\\s+)?(,|[.!?])(\\s+)?/u"; if (($temp[$i] == "." || $temp[$i] == "!" || $temp[$i] == "?") && ($temp[$i + 1] == " ")){ } } return $temp; } $result = fixText($text); echo "{$result}\n";
Standard input is empty
array(83) { [0]=> string(2) "н" [1]=> string(2) "у" [2]=> string(1) " " [3]=> string(2) "ч" [4]=> string(2) "т" [5]=> string(2) "о" [6]=> string(1) "." [7]=> string(1) " " [8]=> string(2) "н" [9]=> string(2) "е" [10]=> string(1) " " [11]=> string(2) "с" [12]=> string(2) "м" [13]=> string(2) "о" [14]=> string(2) "т" [15]=> string(2) "р" [16]=> string(2) "е" [17]=> string(2) "л" [18]=> string(1) " " [19]=> string(2) "е" [20]=> string(2) "щ" [21]=> string(2) "е" [22]=> string(1) " " [23]=> string(1) "b" [24]=> string(1) "l" [25]=> string(1) "a" [26]=> string(1) "c" [27]=> string(1) "k" [28]=> string(1) " " [29]=> string(1) "m" [30]=> string(1) "e" [31]=> string(1) "s" [32]=> string(1) "a" [33]=> string(1) "." [34]=> string(1) " " [35]=> string(2) "я" [36]=> string(1) " " [37]=> string(2) "с" [38]=> string(2) "о" [39]=> string(2) "б" [40]=> string(2) "и" [41]=> string(2) "р" [42]=> string(2) "а" [43]=> string(2) "л" [44]=> string(2) "с" [45]=> string(2) "я" [46]=> string(1) " " [47]=> string(2) "с" [48]=> string(2) "к" [49]=> string(2) "а" [50]=> string(2) "ч" [51]=> string(2) "а" [52]=> string(2) "т" [53]=> string(2) "ь" [54]=> string(1) "," [55]=> string(1) " " [56]=> string(2) "н" [57]=> string(2) "о" [58]=> string(1) " " [59]=> string(2) "в" [60]=> string(2) "с" [61]=> string(2) "е" [62]=> string(1) " " [63]=> string(2) "к" [64]=> string(2) "а" [65]=> string(2) "к" [66]=> string(1) "-" [67]=> string(2) "т" [68]=> string(2) "о" [69]=> string(1) " " [70]=> string(2) "н" [71]=> string(2) "е" [72]=> string(2) "к" [73]=> string(2) "о" [74]=> string(2) "г" [75]=> string(2) "д" [76]=> string(2) "а" [77]=> string(1) " " [78]=> string(2) "б" [79]=> string(2) "ы" [80]=> string(2) "л" [81]=> string(2) "о" [82]=> string(1) "." } array(83) { [0]=> string(2) "Н" [1]=> string(2) "у" [2]=> string(1) " " [3]=> string(2) "ч" [4]=> string(2) "т" [5]=> string(2) "о" [6]=> string(1) "." [7]=> string(1) " " [8]=> string(2) "н" [9]=> string(2) "е" [10]=> string(1) " " [11]=> string(2) "с" [12]=> string(2) "м" [13]=> string(2) "о" [14]=> string(2) "т" [15]=> string(2) "р" [16]=> string(2) "е" [17]=> string(2) "л" [18]=> string(1) " " [19]=> string(2) "е" [20]=> string(2) "щ" [21]=> string(2) "е" [22]=> string(1) " " [23]=> string(1) "b" [24]=> string(1) "l" [25]=> string(1) "a" [26]=> string(1) "c" [27]=> string(1) "k" [28]=> string(1) " " [29]=> string(1) "m" [30]=> string(1) "e" [31]=> string(1) "s" [32]=> string(1) "a" [33]=> string(1) "." [34]=> string(1) " " [35]=> string(2) "я" [36]=> string(1) " " [37]=> string(2) "с" [38]=> string(2) "о" [39]=> string(2) "б" [40]=> string(2) "и" [41]=> string(2) "р" [42]=> string(2) "а" [43]=> string(2) "л" [44]=> string(2) "с" [45]=> string(2) "я" [46]=> string(1) " " [47]=> string(2) "с" [48]=> string(2) "к" [49]=> string(2) "а" [50]=> string(2) "ч" [51]=> string(2) "а" [52]=> string(2) "т" [53]=> string(2) "ь" [54]=> string(1) "," [55]=> string(1) " " [56]=> string(2) "н" [57]=> string(2) "о" [58]=> string(1) " " [59]=> string(2) "в" [60]=> string(2) "с" [61]=> string(2) "е" [62]=> string(1) " " [63]=> string(2) "к" [64]=> string(2) "а" [65]=> string(2) "к" [66]=> string(1) "-" [67]=> string(2) "т" [68]=> string(2) "о" [69]=> string(1) " " [70]=> string(2) "н" [71]=> string(2) "е" [72]=> string(2) "к" [73]=> string(2) "о" [74]=> string(2) "г" [75]=> string(2) "д" [76]=> string(2) "а" [77]=> string(1) " " [78]=> string(2) "б" [79]=> string(2) "ы" [80]=> string(2) "л" [81]=> string(2) "о" [82]=> string(1) "." } Ну что. Не смотрел еще black mesa. Я собирался скачать, но все как-то некогда было.