Sometimes when we display an article, we may need to set broken some keywords and highlight them so that we can quickly find and locate them, so let's take a look at the implementation code.
/** * Keyword Set Broken method * @access public * @param array $options parameter arrays * <li> $info _arr Array Contents </li> * <li> $search _arr array keyword arrays </li> * @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_arra
Y ($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", "<font color= ' red ' >{$search _str}</font>", $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 June ';
$info _arr = Array (' photo_title ' => ' Womejiojd we all surround the static low fart, small June chicken frozen, bubble footbath big ');
$search _arr = Array (' Xiao June ');
$ret = set_arr_keyword_red ($info _arr, $search _arr); Dump ($ret);