note 49776 added to function.array-search
| From: | thiago at explosiondigital dot com | Date: | Tue, 08 Feb 2005 15:20:36 +0000 |
| Subject: | note 49776 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-84665@lists.php.net to get a copy of this message | ||
<?
function RetiraRepetidas($Texto)
{
//\\ Desenvolvido por Thiago Mata - Esta Linha não deve ser Removida //\\
//\\ Made by Thiago Mata - This Line should not be removed //\\
$Pontuacao = ". , ! ? ; ( ) { } [ ] \" ' / \ )";
$Pontuacao = explode(" ",$Pontuacao);
foreach($Pontuacao as $Ponto)
$Texto = str_replace($Ponto," ".$Ponto." ",$Texto);
$Texto = " ".$Texto;
$Array = explode(" ",$Texto);
$newArray = array();
foreach ($Array as $Item)
{
$Aparicoes = array_search($Item,$newArray);
if ($Aparicoes == 0)
{
$newArray[] = $Item;
}
}
unset($newArray[0]);
$NovoTexto = implode(" ",$newArray);
foreach($Pontuacao as $Ponto)
$NovoTexto = str_replace(" ".$Ponto." ",$Ponto,$NovoTexto);
return $NovoTexto;
}
$Texto = "muitas, muitas! palavras {muito muito} repetidas palavras muitas vezes, muito muito
obrigado";
$NovoTexto = RetiraRepetidas($Texto);
print $NovoTexto;
// out - muitas,! palavras {muito} repetidas vezes obrigado
?>
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49776
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49776&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49776&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49776&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49776&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49776&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49776&report=yes
Search -- http://master.php.net/manage/user-notes.php