Съкращение на текст

Nazi_93

Registered
Здравейте,как мога да направя
"Гошо заяви,че е пълен тъпанар на конференцията"
на
"Гошо заяви,че е...."

пробвах със сsubstr ,но ми излизат някакви простотии " �ошо заяв,че е пълен тъпанар на конференцията"
Ето и малко код:
PHP:
	<?php
	require 'config.php';
		$news_select="SELECT * FROM `news`  ORDER BY `id` DESC LIMIT 3";
		$sql=mysql_query($news_select) or die (mysql_error());
		while ($row=mysql_fetch_array($sql)){
		?>
			<a href="last_new.php?id=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a> <br/>
		<?php
		$text=$row['content'];
		$content=substr("$text",-15);
		echo $content."<br/>";
		}
	?>
Благодаря предварително!
 
PHP:
     <?php
        require 'config.php';
                $news_select="SELECT * FROM `news`  ORDER BY `id` DESC LIMIT 3";
                $sql=mysql_query($news_select) or die (mysql_error());
                while ($row=mysql_fetch_array($sql)){
                ?>
                        <a href="last_new.php?id=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a> <br/>
                <?php
                $text=$row['content'];
                $content=mb_substr("$text",-15,'UTF8');
                echo $content."<br/>";
                }
        ?>
 
Така дава
PHP:
 <?php
        require 'config.php';
                $news_select="SELECT * FROM `news`  ORDER BY `id` DESC LIMIT 3";
                $sql=mysql_query($news_select) or die (mysql_error());
                while ($row=mysql_fetch_array($sql)){
                ?>
                        <a href="last_new.php?id=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a> <br/>
                <?php
                $text=$row['content'];
                $content=mb_substr("$text",-15,'UTF8');
                echo $content."<br/>";
                }
        ?>
 
PHP:
	<?php
	require 'config.php';
		$news_select="SELECT * FROM `news`  ORDER BY `id` DESC LIMIT 3";
		$sql=mysql_query($news_select) or die (mysql_error());
		while ($row=mysql_fetch_array($sql)){
		?>
			<a href="last_new.php?id=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a> <br/>
		<?php
		$text=$row['content'];
$content = (strlen($text) > 15) ? substr($text, 0, 15).'...' : $text;
		echo $content."<br/>";
		}
	?>
:?:
 
PHP:
        <?php
        require 'config.php';
                $news_select="SELECT * FROM `news`  ORDER BY `id` DESC LIMIT 3";
                $sql=mysql_query($news_select) or die (mysql_error());
                while ($row=mysql_fetch_array($sql)){
                ?>
                        <a href="last_new.php?id=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a> <br/>
                <?php
                $text=$row['content'];
$content = (strlen($text) > 15) ? mb_substr($text, 0, 15,'UTF8').'...' : $text;
                echo $content."<br/>";
                }
        ?>
 

Back
Горе