dmccabe Posted August 15, 2008 Share Posted August 15, 2008 This is probably something really obvious, but for some reason I just cant get it right. $dirname = trim($row['name']," "); /*This creates a trimmed name without spaces to allow branch local directions to work*/ echo $dirname; I was wanting to take any spaces out of the $row['name'] value, however it doesnt seem to take them out at all. What am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/119798-solved-trim-function-not-doing-as-i-would-expect/ Share on other sites More sharing options...
JasonLewis Posted August 15, 2008 Share Posted August 15, 2008 You can try str_replace(). I believe trim() doesn't remove whitespace from the middle of a string. Something like that anyway. Link to comment https://forums.phpfreaks.com/topic/119798-solved-trim-function-not-doing-as-i-would-expect/#findComment-617174 Share on other sites More sharing options...
ratcateme Posted August 15, 2008 Share Posted August 15, 2008 do you want to completely remove all the spaces so "this is a test" becomes "thisisatest" because trim will only remove from the start or end of a string you need str_replace() Scott. Link to comment https://forums.phpfreaks.com/topic/119798-solved-trim-function-not-doing-as-i-would-expect/#findComment-617175 Share on other sites More sharing options...
dmccabe Posted August 15, 2008 Author Share Posted August 15, 2008 Thanks a lot for the fast response guys. Problem Solved Link to comment https://forums.phpfreaks.com/topic/119798-solved-trim-function-not-doing-as-i-would-expect/#findComment-617176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.