SHARE
TWEET

Untitled

a guest Sep 23rd, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top