mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-08 01:14:24 +03:00
Merge pull request #75 from 1d10t/master
blocks.js, event 'load' => 'loadResponse'; func_text_words, utf-8 support
This commit is contained in:
commit
355b5efb69
|
@ -275,25 +275,11 @@ function func_rmdir($sPath) {
|
||||||
* @param unknown_type $iCountWords
|
* @param unknown_type $iCountWords
|
||||||
*/
|
*/
|
||||||
function func_text_words($sText,$iCountWords) {
|
function func_text_words($sText,$iCountWords) {
|
||||||
$sText=str_replace("\r\n",'[<rn>]',$sText);
|
$aWords = preg_split('#[\s\r\n]+#um',$sText);
|
||||||
$sText=str_replace("\n",'[<n>]',$sText);
|
if($iCountWords < count($aWords)){
|
||||||
|
$aWords = array_slice($aWords,0,$iCountWords);
|
||||||
$iCount=0;
|
|
||||||
$aWordsResult=array();
|
|
||||||
$aWords=preg_split("/\s+/",$sText);
|
|
||||||
for($i=0;$i<count($aWords);$i++) {
|
|
||||||
if ($iCount>=$iCountWords) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ($aWords[$i]!='[<rn>]' and $aWords[$i]!='[<n>]') {
|
|
||||||
$aWordsResult[]=$aWords[$i];
|
|
||||||
$iCount++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$sText=join(' ',$aWordsResult);
|
return join(' ', $aWords);
|
||||||
$sText=str_replace('[<rn>]'," ",$sText);
|
|
||||||
$sText=str_replace('[<n>]'," ",$sText);
|
|
||||||
return $sText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue