MDanz Posted December 9, 2009 Share Posted December 9, 2009 how do i do, if string length is above 7, then display seven characters of the string and put ...(dot dot dot) afterwords.. e.g. 1234567... i started but don't know how to finish $limitz = 7; if (strlen($usern) > $limitz) Link to comment https://forums.phpfreaks.com/topic/184488-help-on-string/ Share on other sites More sharing options...
MDanz Posted December 9, 2009 Author Share Posted December 9, 2009 i got it working.. but now it comes up blank when the take $usern from mysql.. <?php mysql_connect("localhost", "Master", "password"); mysql_select_db("db"); $lastreply = mysql_query("SELECT * FROM Stacks")or die (mysql_error()); while($rowz = mysql_fetch_array($lastreply)){ $usern = $rowz['username']; $limitz = 6; if (strlen($usern) > $limitz) $newname = substr($usern, 0, $limitz) . '..'; echo $newname; } ?> Link to comment https://forums.phpfreaks.com/topic/184488-help-on-string/#findComment-973899 Share on other sites More sharing options...
OOP Posted December 9, 2009 Share Posted December 9, 2009 Hi there, Are you sure that you have some names in your database table with more than 6 characters? Link to comment https://forums.phpfreaks.com/topic/184488-help-on-string/#findComment-973927 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.