PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
What's the best way to calculate the vertical space (in lines of text) taken up by an arbitrary string $string (which may contain newline characters) that is placed into a td cell of width x pixels?
Say using Verdana 12px, 1024x768, and default wrapping behavior.
Depends if you want quick or accurate. For speed you can just count spaces and multply by by an average word length. Most accurate would be to loop through the string, adding up widths and wrapping lines.
feyd, thanks for pointing out those functions. However, I don't understand how these functions could be used to determine the height of text that is constrained by the bounds of a table cell... seems like they just multiply the height of the text font by the number of lines in the text, and they seem to ignore html markup. Is there some way around this?