PHP function substr [closed]

  php, substr

Somehow i cant echo restricted post text, using function substr.

<div class="card">
                <img src="uploads/<?php echo htmlentities($image); ?>" style="max-height:450px;" class="card-img-top img-fluid" />
               <div class="card-body">
                 <h4 class="card-title"> <?php echo htmlentities($postTitle); ?></h4>
                 <small class="text-muted">Posted By <?php echo htmlentities($admin); ?> στις <?php echo htmlentities($dateTime); ?></small>
                 <span style="float:right;" class="badge bg-secondary">20 Comments </span>
                 <hr>
                 <p class="card-text">
                 <?php 
                    if (strlen($postDescription > 50)) {                           
                        $postDescription = substr($postDescription,0,50) . "...";
                    }
                    echo htmlentities($postDescription, ENT_QUOTES, "UTF-8");                                       
                 ?>
                 </p>    
                <a href="fullpost.php?id=<?php echo $postID; ?>" style="float:right;">
                    <span class="btn btn-primary">More >></span>    
                </a>  
                </div>  

            </div>

it shows only full post. When i inspect the code shows me the text into "text here"
Thanks

Source: Ask PHP

LEAVE A COMMENT