Php show 50% of message?

How can I check the amount of charecters message contain and then show 50% of it?

Count the characters using strlen.
http://php.net/manual/en/function.strlen.php

Then substr it at half that value.
http://php.net/manual/en/function.substr.php

Should be able to work it out with these two functions :slight_smile: .

Unless you’re working with UTF8, in which case you will be wanting the multi-byte versions:

mb_strlen() http://php.net/manual/en/function.mb-strlen.php
mb_substr() http://php.net/manual/en/function.mb-substr.php

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.