I only want the first 50 characters of '$output' that has been uploaded to the database to be shown on my page, what is the simplest way for me to do this? If the $output consists of more than 50 characters, I want the text to end on the last word it can without exceeding 50 characters and then put a "..." sort of thing, like a 'read more' section would.
PHP:
<?php
require_once("nbbc/nbbc.php");
$bbcode = new BBCode;
$sql = "SELECT * FROM posts ORDER BY id DESC";
$res = mysqli_query($dbCon, $sql) or die(mysqli_error($dbCon));
$posts = "";
if(mysqli_num_rows($res) > 0) {
while($row = mysqli_fetch_assoc($res)) {
$id = $row['id'];
$title = $row['title'];
$subtitle = $row['subtitle'];
$content = $row['content'];
$date = $row['date'];
$output = $bbcode->Parse($content);
$posts .= "<div id='post'><h2><a href='view_post.php?pid=$id' target='_blank'>$title</a></h2><h3 id='subtitle'>$subtitle</h3><h3 id='datethingy'><span style='color: #457F2C;'>Last updated:</span> $date</h3><p>$output</p></div>";
}
echo $posts;
}else {
echo "There are no posts to be displayed.";
}
?>