For example:
<?php
$string = 'Foo bar';
$length = strlen($string);
echo '<div style="width: '.$length.'px;">'.$string.'</div>';
The above obviously does not work, as $length is 7 and 7px is smaller than the size of the outputted text.
I also understand that font size and other factors will come into play, as well.
What I'm looking for is something like this:
<div style="width:xxx; float:left;">Label 1</div><input type="checkbox"/><br/>
<div style="width:xxx; float:left; clear:left;">Longer Label 2</div> <input type="checkbox"/><br/>
<div style="width:xxx; float:left; clear:left;">Even Longer Label 3</div> <input type="checkbox"/><br/>