Sensitive word search problem functiontransgress_keyword ($ content) {define methods for handling illegal Keywords & nbsp; $ keywordarray (tomorrow's technology, programming dictionary, tomorrow's books, tomorrow's software ); define sensitive words & nbsp; $ m0 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
Add this option.