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 Quote 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); Quote 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 Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/247439-trim-problem/#findComment-1270700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.