Heh :) A function should, however, handle out-of-bounds inputs as gracefully as possible. It's a basic principle of programming.
I still think cutting the string more than the user explicitly requested is ugly and unintuitive to the user.
Printable View
Heh :) A function should, however, handle out-of-bounds inputs as gracefully as possible. It's a basic principle of programming.
I still think cutting the string more than the user explicitly requested is ugly and unintuitive to the user.
It's about fitting it somewhere, not cutting the string. Name it fit2len($str,$len,$tail), and maybe that makes more sense. We may be seeing it as solving different problems.
Out-of-bounds inputs are usually dealt with by errors. Add an error if you'd like.
It does make more sense like that, but as you say, that's a different problem.
I didn't say I was solving a different problem, but that we were. Alex wants to display a preview in a limited region, meaning that he would want it to not overfill the space (probably thereby stretching his layout).Quote:
Originally Posted by me