Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(-1);
- mb_internal_encoding('utf-8');
- $string='Кажется, нас обнаружили! Зима близко?';
- function generalPda($y){
- $t=preg_replace_callback('/([\w\s,]+)(?=[.!?])/u',
- function($x){
- $x=mb_strtolower($x[0]);$x=preg_split('/[\s,]/u',$x,-1,PREG_SPLIT_NO_EMPTY);$new=[];
- for ($i=count($x)-1;$i>=0;$i--){
- array_push($new,$x[$i]);}
- $x=implode(' ',$new);
- $x=preg_replace_callback('/^\w/u',function($match){return mb_strtoupper($match[0]);}, $x);
- return $x;
- },
- $y);
- $t=preg_replace('/([.!?])(?!\s)(\w+)/u', "$1 $2", $t);
- print_r($t);
- }
- generalPda($string);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment