wordpress php: Truncate string. Acf excerpt
<?php if( get_field('preparation') ): ?>
<div class="blogExcerpt-excerpt">
<?php
$prep = get_field('preparation');
$prep = strip_tags($prep);
// echo substr($prep,1);
$prep = substr($prep, 0, 100-3);
$lastSpace = strrpos($prep, ' ');
$prep = substr($prep, 0, $lastSpace);
$prep .= '...';
echo $prep;
?>
</div>
<?php endif; ?>