lopes_andre Posted April 4, 2009 Share Posted April 4, 2009 Hi, I need to "cut" strings. If the string have more than 10 characters, the aditional characters will be cuted. Example: String = "Example testing"; String_cuted = "Example te"; How to do this? Best Regards, André. Link to comment https://forums.phpfreaks.com/topic/152578-how-to-cut-a-string/ Share on other sites More sharing options...
charleshill Posted April 4, 2009 Share Posted April 4, 2009 function cut_string($str, $length) { return strlen($str) > $length ? substr($str, 0, $length) : $str; } Link to comment https://forums.phpfreaks.com/topic/152578-how-to-cut-a-string/#findComment-801351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.