PHP randomly extracts titles from the content _ PHP Tutorial

Source: Internet
Author: User
PHP randomly extracts titles from the content .? Php $ temp $ LabelArray [content]; $ temppreg_replace (% [^] + %, $ temp); prevents matching of letters in the URL $ tempmake_semiangle ($ temp ); half-width conversion if (preg_match_all (% [[: punct:] ([^ [: pu

$ Temp = $ LabelArray ['content'];

$ Temp = preg_replace ("% <[^>] +> %", ',', $ temp); // prevent matching of letters on the website

$ Temp = make_semiangle ($ temp); // halfwidth 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];

}

// Halfwidth rotation

Function make_semiangle ($ str)

{

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

'5' => '5', '6' => '6', '7' => '7', '8' => '8 ', '9' => '9 ',

'A' => 'A', 'B' => 'B', 'c' => 'C', 'D' => 'D ', 'E' => 'e ',

'F' => 'F', 'G' => 'G', 'H' => 'h', 'I' => 'I ', 'j' => 'J ',

'K' => 'K', 'L' => 'L', 'M' => 'm', 'n' => 'N ', 'o' => 'O ',

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

'U' => 'u', 'V' => 'V', 'W' => 'W', 'x' => 'X ', 'y' => 'y ',

'Z' => 'Z', 'a' => 'A', 'B' => 'B', 'c' => 'C ', 'D' => 'D ',

'E' => 'e', 'F' => 'F', 'G' => 'G', 'H' => 'h ', 'I' => 'I ',

'J' => 'J', 'K' => 'K', 'L' => 'L', 'M' =>'m ', 'n' => 'N ',

'O' => 'O', 'P' => 'P', 'q' => 'Q', 'R' => 'R ','s '=>'s ',

'T' => 'T', 'u' => 'u', 'V' => 'V', 'W' => 'W ', 'X' => 'X ',

'Y' => 'y', 'Z' => 'Z ',

'(' => '(', ')' => ')', '[' => '[', ']' => ']', '[' => '[',

']' => ']', '<' => '[', '<' => ']', '=> '[', '"' => ']',

''' => '[', ''' => ']', '{' => '{', '}' => '}', '=>' <',

'"' => ',

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

':' => ':','. '=>'. ',', '=>', '=>'. ',', '=> '.',

';' => ',','? '=> '? ','! '=> '! ','... '=>'-', ''' =>' | ',

'"' => '"', ''' => ''', ''' => ''', '|' => '| ', 'Region' => '"',

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

'"' => '"');

Return strtr ($ str, $ arr );

}

Echo serialize ($ LabelArray );

?>

Http://www.bkjia.com/PHPjc/478087.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478087.htmlTechArticle? Php $ temp = $ LabelArray [content]; $ temp = preg_replace (% [^] + %, $ temp ); // prevent matching letters in the website from $ temp = make_semiangle ($ temp); // Convert the if (preg_match_all (% [[: punct:] ([^ [: pu...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.