flemingmike Posted October 7, 2010 Share Posted October 7, 2010 hello, is there a wat to limit the following to only the first 25 characters? $customername=$row1["customer"]; thanks Link to comment https://forums.phpfreaks.com/topic/215331-is-there-a-way-to-limit-results/ Share on other sites More sharing options...
liamoco Posted October 7, 2010 Share Posted October 7, 2010 $length = strlen($customername); if ($length > 25) $customername = substr($customername, 0, -25); Link to comment https://forums.phpfreaks.com/topic/215331-is-there-a-way-to-limit-results/#findComment-1119764 Share on other sites More sharing options...
flemingmike Posted October 7, 2010 Author Share Posted October 7, 2010 thanks Link to comment https://forums.phpfreaks.com/topic/215331-is-there-a-way-to-limit-results/#findComment-1119765 Share on other sites More sharing options...
liamoco Posted October 7, 2010 Share Posted October 7, 2010 Oops my bad try this... $limit = 25; $length = strlen($customername); if ($length > $limit) { $remove = $limit - $length; $customername = substr($customername, 0, $remove); } Link to comment https://forums.phpfreaks.com/topic/215331-is-there-a-way-to-limit-results/#findComment-1119768 Share on other sites More sharing options...
flemingmike Posted October 7, 2010 Author Share Posted October 7, 2010 that worked much better! Link to comment https://forums.phpfreaks.com/topic/215331-is-there-a-way-to-limit-results/#findComment-1119775 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.