0) { $texto = str_replace(" "," ",$texto); } $texto = eregi_replace("
"," ",$texto); $texto = str_replace("-"," - ",$texto); while (strpos($texto," ") > 0) { $texto = str_replace(" "," ",$texto); } $texto = strip_tags($texto); // transformando o texto em array $array_texto = split(" ",$texto); //varre o texto a procura das palavras $chaves = ""; $array_texto_minusculas = array_map("strtolower",$array_texto); $array_minusculas = array_map("strtolower",$array); for($i=0;$i=$i-5; $o--) { $chaves .= $o." "; } for($o=$i; $o<=$i+5; $o++) { $chaves .= $o." "; } } } $chaves = trim($chaves); if(empty($chaves)) { $texto = substr($texto,0,60)."..."; return $texto; } $chaves = split(" ",$chaves); sort($chaves); $chaves = array_unique($chaves); $trecho = ""; foreach($chaves as $i) { if(array_key_exists($i,$array_texto_minusculas)) { $abre_b = ""; $fecha_b = ""; if(in_array($array_texto_minusculas[$i],$array_minusculas)) { $abre_b = ""; $fecha_b = ""; } $trecho .= $abre_b.$array_texto[$i].$fecha_b." "; } } //tratando o trecho $trecho = str_replace(" - ","-",$trecho); $trecho = trim($trecho); return $trecho; } function quebra_de_linha($texto) { if(!empty($texto)) { $texto = nl2br($texto); } return $texto; } function print_pre($array) { echo "
".print_r($array,1)."
"; } ?>