onedumbcoder Posted June 24, 2009 Share Posted June 24, 2009 is this a bad idea $e = substr($post['title'], 0, 40); if there is a chance that title might be less the 40chars long? lets say the title is only 4 chars long, will it add 36 empty spaces? or am i fine using that. Thank you and as always appreciate the help. Quote Link to comment Share on other sites More sharing options...
vbnullchar Posted June 24, 2009 Share Posted June 24, 2009 check: http://us3.php.net/manual/en/function.str-pad.php Quote Link to comment Share on other sites More sharing options...
pkedpker Posted June 24, 2009 Share Posted June 24, 2009 is this a bad idea $e = substr($post['title'], 0, 40); if there is a chance that title might be less the 40chars long? lets say the title is only 4 chars long, will it add 36 empty spaces? or am i fine using that. Thank you and as always appreciate the help. <?php $sizeOfe = $strlen($e); $e = substr($post['title'], 0, sizeOfe < 40 ? sizeOfe : 40); ?> Quote Link to comment Share on other sites More sharing options...
akitchin Posted June 24, 2009 Share Posted June 24, 2009 i don't suppose you've thought about passing it a test string to see? substr() won't pad the string; if the length is longer than the string, it will simply return the string. Quote Link to comment Share on other sites More sharing options...
onedumbcoder Posted June 24, 2009 Author Share Posted June 24, 2009 thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.