Sensitive word search problem functiontransgress_keyword ($ content) {// define the method for handling illegal Keywords & nbsp; $ keyword = array ('Tomorrow's Tech ', 'programming dictionaries ', 'books tomorrow, 'software tomorrow '); // defines sensitive words & nb sensitive word search problems
Function transgress_keyword ($ content) {// defines the method for handling illegal keywords
$ Keyword = array ('Tomorrow technology ', 'programming Dictionary', 'Tomorrow Books ', 'Tomorrow software'); // defines sensitive words
$ M = 0;
For ($ I = 0; $ I <count ($ keyword); $ I ++) {// execute the for loop based on the number of array elements
// Apply substr_count to check whether the title and content of an article contain sensitive words.
If (substr_count ($ content, $ keyword [$ I])> 0 ){
$ M ++;
}
}
Return $ m;
}
I found the sensitive word search code on the Internet, but when I put $ keyword = array ('Tomorrow technology ', 'programming Dictionary', 'Tomorrow Books ', 'Tomorrow software ') replace
$ Keyword = file ("f: \ mgc \ test.txt"); m is always 0. What is the problem? the path and file exist.
Print_r can also be used to output file ("f: \ mgc \ test.txt.
------ Solution --------------------
FILE_IGNORE_NEW_LINES
Do not add newline at the end of each array element
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