Home >Backend Development >PHP Tutorial >PHP randomly extracts titles from content_PHP tutorial

PHP randomly extracts titles from content_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:52:421336browse

$temp=$LabelArray['content'];

$temp=preg_replace("%<[^>]+>%",',',$temp);//Prevent letters in the URL from being matched

$temp=make_semiangle($temp);//Half-width conversion

if(preg_match_all("%[[:punct:]]([^[:punct:]]{5,30})[[:punct:]]%u",$temp,$arr)){

$i=rand(0,count($arr[0])-1);

$LabelArray['Title']=$arr[1][$i];

}

//Full-width and half-width rotation

function make_semiangle($str)

{

$arr = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4 ' => '4',

> 9',

> E',

> J',

> O',

                    'P' => 'P', 'Q' => 'Q', 'R' => T',

                   'U' => 'U', 'V' => Y',

> d',

> i',

'n' n',

> s',

> x',

'y' => 'y', 'z' => 'z',

> [',

                  ']' => ']', '〖' => ]',

                 '‘' => '[', '’' => ']', '{' => '{', '}' => '}', '《' => '<', 

                 '》' => '>', 

                 '%' => '%', '+' => '+', '—' => '-', '-' => '-', '~' => '-', 

                 ':' => ':', '。' => '.', '、' => ',', ',' => '.', '、' => '.', 

                 ';' => ',', '?' => '?', '!' => '!', '…' => '-', '‖' => '|', 

                 '”' => '"', '’' => '`', '‘' => '`', '|' => '|', '〃' => '"', 

                 ' ' => ' ','$'=>'$','@'=>'@','#'=>'#','^'=>'^','&'=>'&','*'=>'*',

                 '"'=>'"');

     return strtr($str, $arr); 

}

echo serialize($LabelArray);

?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478087.htmlTechArticle?php $temp=$LabelArray[内容]; $temp=preg_replace(%[^]+%,,,$temp);//防止网址中字母被匹配 $temp=make_semiangle($temp);//半角转化 if(preg_match_all(%[[:punct:]]([^[:pu...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn