Destramic Posted September 19, 2011 Share Posted September 19, 2011 ive used trim to get rid of the end of a a string and it takes an extra character off it anyone can help please $class_name = "League_Model"; echo $model_name = trim($class_name, "_Model"); result: Leagu im want it to return: league Link to comment https://forums.phpfreaks.com/topic/247439-trim-problem/ Share on other sites More sharing options...
dougjohnson Posted September 19, 2011 Share Posted September 19, 2011 You probably want to use SUBSTR: $class_name = "League_Model"; echo $model_name = substr($class_name,0,6); Link to comment https://forums.phpfreaks.com/topic/247439-trim-problem/#findComment-1270689 Share on other sites More sharing options...
ManiacDan Posted September 19, 2011 Share Posted September 19, 2011 trim()'s second argument is a LIST of characters to remove, not a STRING to remove. You can use substr or simply str_replace: $a = str_replace("_league". '', $a); -Dan Link to comment https://forums.phpfreaks.com/topic/247439-trim-problem/#findComment-1270691 Share on other sites More sharing options...
Destramic Posted September 19, 2011 Author Share Posted September 19, 2011 thanks for your help guys Link to comment https://forums.phpfreaks.com/topic/247439-trim-problem/#findComment-1270700 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.