I am pulling some data from a JSON source in a PHP loop and want to character limit/restrict one of the data nodes I render. I have used:
<?php echo $character['description'] = substr($character['description'],0,250).'...'; ?>
But this means each time the loop is called and the next set of results are echoed - the number of limited characters increases... Is there a way to get ALL 'description' strings to be capped to 250 characters with a '...' added after?
loop code is:
<?php foreach ($characters as $character) : ?>
<p class="description"><?php echo $character['description']; ?></p>
<?php endforeach; ?>