Scenario :
- I have used a text editor to input my large content ( Wordpress ).
So, now the content is to be displayed at homepage so i use the php queries to display the content.
Now, i need the content to be in a size of 100-200 so i have used substr() function of php in order to do so.
Also, i need the content to be displayed with different html tags involved in my homepage.
Function Code:
$text = get_field('independent_excerpt', $post->ID);
if (strlen($text) > $length) {
$text = substr($text,0,strpos($text,' ',$length)) . '<a class="link_custom_evidenz" href="' . get_permalink() . '">[Leggi Tutto]</a>';
}
Output Code:
<?php echo cstom_function_excerpt(100); ?>
So the above code o/p's the contents correctly but the content breaks my other div's and styles becasuse due to substr() function the html tags are not being properly closed.
So, my question is how do i solve this issue of self closing the html tags when i use the substr() function so that my style's and layout does not end of messing ??
I have searched this issue but failed to achieve any related and good answer. So, please help me to solve this issue.. !!
Thanx