Page is a not externally linkable
swa66 - 10:25 pm on Oct 22, 2012 (gmt 0)
1 the function strstr could be used to split it in a first and second part, where the first is 200 chars long. Take care if you have a multibyte encoding like UTF-8, then you need mb_substr!
There's also mb_strimwidth, which gets even closer to what you seek.
Ref: [php.net...]
Ref: [php.net...]
Ref: [php.net...]
2. It's VERY difficult to predict how all browsers will convert characters into pixels. In essence: you have no chance. The only thing you could do is count on a hidden overflow in CSS, add in some fading/scrolling etc. and you can get the best of both worlds there,
But the server knwoing how long it will be in pixels: forget it. At best you might get a clue, but that requires knowledge of what font will chosen by the browser and how wide every character will be.
3. You could search for the last space in the first substring and then shorten it relative to the found position.
Ref: [php.net...]
Ref: [php.net...]
Or you could find the fisrt occurance of a space in the second part andthen add the relevant part back to the first part.
Ref: [php.net...]
Ref: [php.net...]
Again: the mb- varaints for for multi byte encodings such as UTF-8 UTF-16 etc ...
4. Once you know how to cut off at spaces, the periods become easy :-0
5. It's the same agin, but you need to first define how you encode paragraphs :-)