We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Sub String problem.

how can i write this in substring with phalcon

{{blog.description}}

plz help me.



11.0k

Can you explain more ? I don't know what you want to do.

i want ot view my description in upto 200 char. like this. <?php echo mb_strimwidth("Hello World", 0, 10, "..."); ?>

but don't know. how to show it with phalcon.

i'm print my description in this system.

{{blog.description}}



125.8k
Accepted
answer

You can add mb_strimwidth as a Volt function, but the simplest might be to just use plain PHP in your Volt template - that is possible. {{blog.description}}, when referenced in straight PHP is $blog->description.

edited Sep '15

solution for substring....

<?php
if($blog->description) { echo substr($blog->description, 0,200); } ?>