![]() |
[Tip] Limiting a strings length
Below is a handy function for shortening a string, where space is needed...
PHP Code:
PHP Code:
|
Heheh, easy.
Thanks :) |
It's a very simple function, but I'm going to be picky (it's late here and this is what I do when I'm tired).
|
bleh, way to be picky.
Anyway, will update the main post.... And the reason for $szOutput being assigned? simply for readability, this is for beginners remember. PHP Code:
|
Lol! Be nice to Salathe. He's only helping everyone out and that's why we're here. Perhaps we do need some further information on the ternary operator if you were going to use that in your function example.
|
Hey great function been looking for a little tidbit like this for quite some time, it's perfect for my current project! :-)
|
Quote:
|
Here's my effort:
PHP Code:
It does share the same issue as Will's function; the ellipsis isn't taken into consideration with $maxLen. I personally use the ellipsis symbol instead of 3 full stops. |
| All times are GMT. The time now is 01:45 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0