Forum Moderators: coopster
<?
$tagArray = array();
$tags = "Jack and Jenny are going to the bus stop";
foreach (str_word_count($tags,1,'áé‘') as $tag )
{
array_key_exists ( $tag, $tagArray ) ? $tagArray[ $tag ]++ : $tagArray[ $tag ] = 0;
}
function clouds( $tagArray = array() )
{
foreach( $tagArray as $tag => $say )
{
$tag=mb_strtolower($tag, 'UTF-8');
$cloudArray[] = '<a class="tag" href="tags/'.$tag.'" title="'.$tag.'">'. htmlspecialchars( stripslashes( $tag ) ) . '</a>';
}
return join( "\n", $cloudArray ) . "\n";
}
echo clouds( $tagArray );
?> <?php
$str = 'Jack and Jenny are going to the bus stop';
$words = explode(' ', trim($str));
$strOut = '';
foreach ($words as $word) {
if (strlen($word) > 3) {$strOut .= $word . ' ';}
}
$strOut = trim($strOut);
echo $strOut; //output string
?>
foreach (str_word_count($tags,1,'áéíóú‘') as $tag ) $tag=mb_strtolower($tag, 'UTF-8'); function clouds( $tagArray = array() )
{
foreach( $tagArray as $tag => $say )
{
if (strlen($tag) < 4) continue;
:
function clouds( $tagArray = array() )
{
foreach( $tagArray as $tag => $say )
{
if (strlen($tag) < 4) continue;
$tag=mb_strtolower($tag, 'UTF-8');
$cloudArray[] = '<a class="tag" href="tags/'.$tag.'" title="'.$tag.'">'. htmlspecialchars( stripslashes( $tag ) ) . '</a>';
}
return join( "\n", $cloudArray ) . "\n";
}
[edited by: penders at 12:00 pm (utc) on Jun 27, 2011]
[edited by: brotherhood_of_LAN at 12:13 pm (utc) on Jun 27, 2011]