0

以下は、内部 Web サーバーで実行している HTML コードの抜粋です。DB から返されたテキストの PHP の切り捨てを適切に機能させる方法がわかりません。

編集:これは私が見ているものです(25文字と省略記号が必要です)

ここに画像の説明を入力

<html>
<head><title>My Title</title>

<?php
    function truncate($text, $chars = 25) 
    {
        $text = $text." ";
        $text = substr($text,0,$chars);
        $text = substr($text,0,strrpos($text,' '));
        $text = $text."...";
        return $text;
    }
?>
        
</head>
<body>
<div id="mydiv">
    <table class="myTable">
        <tr>
            <td>Col 1</td>
        </tr>
        <?php
        $counter = 0;
        while ($counter < $numRows)
        {
            $f3=mysql_result($result,$counter,"url");
        ?>
        <tr>
            <td>
                <div class="masker">
                    <a href="<?php echo $f3; ?>" target="_blank"><?php echo truncate($f3); ?></a>
                </div>
            </td>
        </tr>
        <?php
            counter++;
        ?>
    </table>
</div>
</body>
</html>

何か案は?ありがとう。

4

3 に答える 3