runnerjp Posted October 27, 2008 Share Posted October 27, 2008 im trying to add '...' if the sting length is longer then 15 <?php echo substr($getthreads3[title],0,15);if ($getthreads3[title]>substr(0,9)) echo '...';?> this is what i thought lol $getthreads3[title]>substr(0,9)) any ideas? Link to comment https://forums.phpfreaks.com/topic/130350-solved-carrying-out-if-statement-on-sting-length/ Share on other sites More sharing options...
rhodesa Posted October 27, 2008 Share Posted October 27, 2008 <?php echo substr($getthreads3[title],0,15); if(strlen($getthreads3[title]) >= 15) echo '...'; ?> Link to comment https://forums.phpfreaks.com/topic/130350-solved-carrying-out-if-statement-on-sting-length/#findComment-676078 Share on other sites More sharing options...
Alt_F4 Posted October 27, 2008 Share Posted October 27, 2008 try this <?php if (str_len($getthreads3[title])>9) { echo substr($getthreads3[title],0,9).'…'; } else { echo substr($getthreads3[title],0,15); } ?> Link to comment https://forums.phpfreaks.com/topic/130350-solved-carrying-out-if-statement-on-sting-length/#findComment-676082 Share on other sites More sharing options...
runnerjp Posted October 27, 2008 Author Share Posted October 27, 2008 rhodesa's code worked ta Link to comment https://forums.phpfreaks.com/topic/130350-solved-carrying-out-if-statement-on-sting-length/#findComment-676112 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.