Basically, I have a while statement and I want to make it so that if the text selected is too long, it will add a break every 20 characters or so.
I have made an attempt, but it isn't working. The main issue with this is on mobile if the text is more than 20 characters, it will go outside the divider its in.
My Whole While Statement:
while ($field = $result->fetch_assoc()) {
if ($columnCount < 10) {
$text = $field["text"];
$newtext = wordwrap($text, 20, "<br />
");
echo '
<div class="well">
<div class="row">
<div class="col-xs-10">
'.$newtext.'<br /><br /><a class="link" href="view.php?id='.$field["id"].'"><b>'.$field["name"].'</b> - '.time_elapsed_string($field["timestamp"]).'</a>
</div>
<div class="col-xs-2 text-center counter">
<form action="like.php?id='.$field["id"].'" method="POST" style="margin-bottom:0px;margin-top:-8%;">
<button class="btn btn-primary btn-sm" type="submit" name="submit" id="submit">▲</button><br />
<input type="hidden" name="id" value="'.$field["id"].'">
</form>
<div class="well well2 text-center" style="padding:0px;margin-bottom:0px;width:100% !important;">
'.$field["likes"].'
</div>
<form action="dislike.php?id='.$field["id"].'" method="POST">
<button class="btn btn-primary btn-sm" type="submit" name="submit" id="submit">▼</button><br />
<input type="hidden" name="id" value="'.$field["id"].'">
</form>
</div>
</div>
</div>';
$columnCount++;
}
}
I made an attempt, but wasn't sure how to get it working exactly. There is no error here, it will appear with the text, but there won't be any break in the line after 20 characters or so.
Here is an image of one of the results that is being displayed with more than 20 characters and no break. If I view the source, there are no breaks either.
Edit: I would post an image of it on mobile, but I can't right now. Basically the text will just go completely outside the box and won't stay inside. It will go off the page and everything.