Tell me please, there is a code that I am pulling data from the table:

<?php $host = 'localhost'; $db = ''; $user = ''; $pass = '; $charset = 'utf8'; $dsn = "mysql:host=$host;dbname=$db;charset=$charset"; $opt = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]; $pdo = new PDO($dsn, $user, $pass, $opt); $stmt = $pdo->query('SELECT * FROM task order by id_t desc'); while ($row = $stmt->fetch()) { echo "<div class='cont' style='height:auto;padding-top:15px;padding-bottom:15px;'> <table style='text-align:center;'> <tr> <td><span style='font-size: 10px;font-weight: bold;color: #777;'>ОПИСАНИЕ</span></td> </tr> <tr> <td>".$row['desc_t']."</td> </tr> </table> </div><br> \n"; } ?> 

How can I limit the number of characters displayed information ".$row['desc_t']."

  • one
    <td>" . mb_substr($row['desc_t'], 0, 5) . "</td> where 0 is the position of the first character and 5 is the length of the substring. If you work with Latin, then the prefix mb_ can be omitted. - Edward
  • one
    @ Edward thank you very much, everything works. - Vladislav Samokhin Nov.

0