shaunno2007 Posted August 17, 2008 Share Posted August 17, 2008 This is about "substr". How can i make so that ... goes on the end of my string but only if it goes over the length? Quote Link to comment Share on other sites More sharing options...
Fadion Posted August 17, 2008 Share Posted August 17, 2008 <?php $str = 'this is some random text'; $maxlength = 10; if(strlen($str) > $maxlength){ echo substr($str, 0, $maxlength); } else{ echo $str; } ?> Quote Link to comment Share on other sites More sharing options...
shaunno2007 Posted August 17, 2008 Author Share Posted August 17, 2008 how can i put it with this cos i have this... <?php while($website_row = mysql_fetch_array($website_result)) { ?> <a href="http://<?php echo $website_row['url']; ?>" target="_blank"><?php echo substr ($website_row['link'], 0, 76). "<br />" ; } ?></a> Quote Link to comment Share on other sites More sharing options...
Fadion Posted August 17, 2008 Share Posted August 17, 2008 <?php while($website_row = mysql_fetch_array($website_result)){ ?> <a href="http://<?php echo $website_row['url']; ?>" target="_blank"> <?php if(strlen($website_row['link']) > 76){ echo substr($website_row['link'], 0, 76) . '<br />' ; } else{ echo $website_row['link']; } ?> </a> <?php } ?> Quote Link to comment Share on other sites More sharing options...
shaunno2007 Posted August 17, 2008 Author Share Posted August 17, 2008 thanks works great 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.