Sometimes when we display an article, we may need to set broken some keywords, highlighting them so that we can quickly find and locate these keywords, let's look at the specific implementation of the code.
/** * Keyword Set Broken method * * @access public * @param array $options parameter arrays *
$info _arr Array Contents*
$search _arr array of keyword arrays * @return int or array */function set_arr_keyword_red ($info _arr, $search _arr) {foreach ($search _arr as $search _str) {foreach ($info _arr as $key = + $info) {if (In_array ($key, Array (' item_title ', ' keywords ', ' photo_title ', ' photo _site ', ' content ',)) {$info = Strip_tags ($info); $info = Str_replace (', ', ', $info); $q _str_pos = Stripos ($info, $search _str); if (false!== $q _str_pos) {$info = Csubstr ($info, $q _str_pos+150); $temp = Csubstr ($info, $q _str_pos-150); $info = substr ($info, strlen ($temp), 300); $info = Preg_replace ("/{$search _str}/i", "{$search _str}", $info); if ($info _arr[' match_key ']== ') $info _arr[' match_key '] = $key; } else {$info = Csubstr ($info, 300); }} $info _arr[$key] = $info; }} return $info _arr; } $str = ' Woloveu '; $info _arr = Array (' photo_title ' = ' Womejiojd we all beat the static low fart ah little June chicken frozen Ah bubble footbath big '); $search _arr = Array (' little June '); $ ret = set_arr_keyword_red ($info _arr, $search _arr);d UMP ($ret);
The above introduces PHP to the text content of the key word set broken processing, including the keyword, PHP content, I hope that the PHP tutorial interested in a friend helpful.