Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hakeempazhu/4d800866a110d4616144e32840d40f3f to your computer and use it in GitHub Desktop.
Save hakeempazhu/4d800866a110d4616144e32840d40f3f to your computer and use it in GitHub Desktop.
Read more option in php with collapse
<p>
<?php
$string = strip_tags($property['description_en']);
$n=strlen($string);
if ($n > 500) {
// truncate string
$newstring = substr($string, 0, 500);
$newstring .= '<span id="more">... <a href="" class="bold" id="viewmore" data-toggle="collapse" data-target="#demo" >Read More</a></span>';
$balance = substr($string,500, $n);
echo $newstring;
}
else
{
echo $string;
}
?><span id="demo" class="collapse"><?php echo $balance; ?></span>
</p>
<!-- JQuery -->
<script>
$("#viewmore").click(function(){
$("#more").hide();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment