Can you help me with strip_tags and strlen
I'm trying to trim a html text to an exact lenght.
I'm ussing strip_tags and strlen on the front page of jabulela but the text length is not always the same.
How to trim to an exact html lenght?
do you know any snippets ?
pr0gr4mm3r posted this at 12:45 — 25th January 2009.
He has: 1,502 posts
Joined: Sep 2006
As long as you strip the tags before getting the string length, you should have no problem getting the proper length that matches all the others.
bloggero posted this at 20:05 — 25th January 2009.
They have: 22 posts
Joined: Oct 2008
I strip tags before before getting the string length, but the problem is in the character length in pixels, or so I think, and I don't know how to solve this.
|electric cars|
|fashion photography|
|velvet cushions|
pr0gr4mm3r posted this at 20:26 — 25th January 2009.
He has: 1,502 posts
Joined: Sep 2006
Oh, ok. So you are looking to get a string width in pixels? PHP does offer the ability to get the dimensions of a string in pixels, using the imagettfbbox() function, but that is only for overlaying text on a graphic.
webwiz posted this at 23:08 — 25th January 2009.
He has: 629 posts
Joined: May 2007
The only way I know to get the size of text on the screen is by using JavaScript. The fonts in your font stack are of different sizes, affecting the number of characters in a line. In addition, there are many settings of both the browser and the computer that affect text size. I don't think there's a way of detecting such settings with PHP.
Even with JavaScript it is tricky, as you need to put the text in a shrink-wrapped container to measure any particular piece of text. Then you have to monitor continuously for changes to browser text size settings.
Can you describe what you hope to achieve, exactly?
Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;
bloggero posted this at 18:05 — 27th January 2009.
They have: 22 posts
Joined: Oct 2008
To print 3 lines of content with html tags included. If I cut too much sometimes are printed 2 lines, if I increase that value sometimes 4 lines are printed.
|electric cars|
|fashion photography|
|velvet cushions|
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.