Vigilant Psyche Posted April 10, 2008 Share Posted April 10, 2008 Hey, guys. If I have a table and it has a long word in it, say "ooooooooooooo" is there a function to add a space where the text becomes too long for the tables? Thanks. Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/ Share on other sites More sharing options...
cooldude832 Posted April 10, 2008 Share Posted April 10, 2008 did u try wordwrap? Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514133 Share on other sites More sharing options...
Vigilant Psyche Posted April 10, 2008 Author Share Posted April 10, 2008 Yeah but I wan't to wrap to pixels, number of letters doesn't help much... Hehe 4,5,6-tri X benzene Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514143 Share on other sites More sharing options...
cooldude832 Posted April 10, 2008 Share Posted April 10, 2008 you have a lot of "letters" and you want to "wrap" them sounds good to me fyi it is 1,2,3-trimethyl-benzene Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514145 Share on other sites More sharing options...
rhodesa Posted April 10, 2008 Share Posted April 10, 2008 You can't wrap to pixels, just to number of characters. You can specify the width of the table column with CSS and it should move the word to the next line. Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514152 Share on other sites More sharing options...
Vigilant Psyche Posted April 10, 2008 Author Share Posted April 10, 2008 Yes but what sort of argument would I use? 10 letters? This would not be appropriate as it would stop short sometimes and overflow other time because eg "M" is longer than "I". So I want to be able to stick in a newline if its over X pixels. Really? I thought we number anticlockwise? Oh no, I have my chem exam in a month! XD EDIT: so it would auto matically split a word that was to long, even if there are no spaces like "ooooooooooooooooooooooooooo"? Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514154 Share on other sites More sharing options...
cooldude832 Posted April 10, 2008 Share Posted April 10, 2008 no u take the whole string and warp it to fit i.e wrap "Marry had a little lamb, its fleece was white as snow"; to say 10 characters becomes "Marry had a little la mb, its fle ece was wh ite as snow" Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514158 Share on other sites More sharing options...
rhodesa Posted April 10, 2008 Share Posted April 10, 2008 Short answer: In my experience there is no way to accomplish what you are trying to do. Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514161 Share on other sites More sharing options...
Vigilant Psyche Posted April 10, 2008 Author Share Posted April 10, 2008 here's what I wan't to do... see how there is an entry in "blogs" which is too long? http://www.scd.simtoz.com/ I need it to fit to the width of the table much like on this site: http://www.64digits.com/ Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514165 Share on other sites More sharing options...
rhodesa Posted April 10, 2008 Share Posted April 10, 2008 I understand...you might be able to find something with Javascript, but with PHP you can only work with the number of characters a string has. There is no way to calculate (from PHP) what the length of each character is and if it will fit. PHP doesn't know how the users browser will interpret the characters. Maybe the browser doesn't have the font you suggest using, so it uses something else. Or maybe the user has selected to have the font on all pages enlarged to make it easier to read. Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514193 Share on other sites More sharing options...
cooldude832 Posted April 10, 2008 Share Posted April 10, 2008 There is no way to calculate (from PHP) what the length of each character is and if it will fit. gd has a way to get a strings size in a give TTF font + font size +font angle, but its not exactly ideal Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514195 Share on other sites More sharing options...
rhodesa Posted April 10, 2008 Share Posted April 10, 2008 yeah, but there are still other factors going into the font size that you can't account for Link to comment https://forums.phpfreaks.com/topic/100522-fitting-text-to-a-table/#findComment-514203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.