function trim_array ($matriz) {
if(is_array($matriz)) {
$matriz = array_map('trim', $matriz);
}
return $matriz;
}
function zerosaesquerda($numero,$digitos) {
while ((strlen($numero) < $digitos)) {
$numero = "0".$numero;
}
return $numero;
}
function ajeitaURL($texto) {
$texto = strtolower($texto);
$texto = str_replace(" ","-",$texto);
$texto = str_replace("\\","",$texto);
$texto = str_replace("/","",$texto);
$texto = str_replace("\"","",$texto);
$texto = str_replace("'","",$texto);
$texto = str_replace("=","",$texto);
$texto = str_replace("@","",$texto);
$texto = str_replace("!","",$texto);
$texto = str_replace("%","",$texto);
$texto = str_replace("£","",$texto);
$texto = str_replace("¬","",$texto);
$texto = str_replace("¢","",$texto);
$texto = str_replace("&","",$texto);
$texto = str_replace("*","",$texto);
$texto = str_replace("(","",$texto);
$texto = str_replace(")","",$texto);
$texto = str_replace("[","",$texto);
$texto = str_replace("]","",$texto);
$texto = str_replace("{","",$texto);
$texto = str_replace("}","",$texto);
$texto = str_replace("º","",$texto);
$texto = str_replace("ª","",$texto);
$texto = str_replace("ª","",$texto);
$texto = str_replace("ç","c",$texto);
$texto = str_replace("ñ","n",$texto);
$texto = str_replace("á","a",$texto);
$texto = str_replace("à","a",$texto);
$texto = str_replace("â","a",$texto);
$texto = str_replace("ã","a",$texto);
$texto = str_replace("ä","a",$texto);
$texto = str_replace("é","e",$texto);
$texto = str_replace("è","e",$texto);
$texto = str_replace("ê","e",$texto);
$texto = str_replace("ë","e",$texto);
$texto = str_replace("í","i",$texto);
$texto = str_replace("ì","i",$texto);
$texto = str_replace("î","i",$texto);
$texto = str_replace("ï","i",$texto);
$texto = str_replace("ó","o",$texto);
$texto = str_replace("ò","o",$texto);
$texto = str_replace("ô","o",$texto);
$texto = str_replace("õ","o",$texto);
$texto = str_replace("ö","o",$texto);
$texto = str_replace("ú","u",$texto);
$texto = str_replace("ù","u",$texto);
$texto = str_replace("û","u",$texto);
$texto = str_replace("ü","u",$texto);
return $texto;
}
function ajeitaconteudo($palavra) {
$palavra = str_replace(chr(10),"",$palavra);
$palavra = str_replace(chr(13),"",$palavra);
$palavra = str_replace("\"","\\\"",$palavra);
$palavra = str_replace("http://".$_SERVER['SERVER_NAME'],"",$palavra);
return $palavra;
}
function grifa_busca ($texto, $array) {
// tratando o texto
while (strpos($texto," ") > 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)."
";
}
?>