scotchegg78 Posted August 27, 2007 Share Posted August 27, 2007 what the devil is going on here... echo $oldqry; $newsql = ltrim($oldqry," AND"); echo $newsql; give this! before trim .. AND NetworkID LIKE after trim...etworkID LIKE '3 wheres my N gone! Quote Link to comment https://forums.phpfreaks.com/topic/66947-stupid-question-ltrim-hates-the-letter-n/ Share on other sites More sharing options...
Hypnos Posted August 27, 2007 Share Posted August 27, 2007 Because you set the second parameter on ltrim. The second parameter is what characters you want to strip. Looks like you're trying to strip away that "AND". This is a slightly better way: $newsql = str_replace(" AND", $oldqry); Quote Link to comment https://forums.phpfreaks.com/topic/66947-stupid-question-ltrim-hates-the-letter-n/#findComment-335744 Share on other sites More sharing options...
scotchegg78 Posted August 28, 2007 Author Share Posted August 28, 2007 hi thanks for the reply, but will this not replace all " AND" s in the string? there may be many of these. And i know i want it to strip the word AND from the start, but not the N from NetworksID ?! Quote Link to comment https://forums.phpfreaks.com/topic/66947-stupid-question-ltrim-hates-the-letter-n/#findComment-336059 Share on other sites More sharing options...
MadTechie Posted August 28, 2007 Share Posted August 28, 2007 try this $newsql = preg_replace('/^AND|AND$/si', '', $oldqry); EDIT: Opps Ltrim version $newsql = preg_replace('/^AND/si', '', $oldqry); Rtrim version $newsql = preg_replace('/AND$/si', '', $oldqry); Quote Link to comment https://forums.phpfreaks.com/topic/66947-stupid-question-ltrim-hates-the-letter-n/#findComment-336062 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.