Guest User

Untitled

a guest
Sep 23rd, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2. error_reporting(-1);
  3. mb_internal_encoding('utf-8');
  4. $string='Кажется, нас обнаружили! Зима близко?';
  5.  
  6. function generalPda($y){
  7.  
  8. $t=preg_replace_callback('/([\w\s,]+)(?=[.!?])/u',
  9.  
  10. function($x){
  11. $x=mb_strtolower($x[0]);$x=preg_split('/[\s,]/u',$x,-1,PREG_SPLIT_NO_EMPTY);$new=[];
  12. for ($i=count($x)-1;$i>=0;$i--){
  13. array_push($new,$x[$i]);}
  14. $x=implode(' ',$new);
  15. $x=preg_replace_callback('/^\w/u',function($match){return mb_strtoupper($match[0]);}, $x);
  16. return $x;
  17. },
  18.  
  19. $y);
  20.  
  21. $t=preg_replace('/([.!?])(?!\s)(\w+)/u', "$1 $2", $t);
  22.  
  23. print_r($t);
  24. }
  25.  
  26. generalPda($string);
  27.  
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment