gammaman Posted May 4, 2008 Share Posted May 4, 2008 lets say I have a statement $var= " name"; How would I combine ltrim and ucfirst togther to get $var="Name"; Link to comment https://forums.phpfreaks.com/topic/104051-help-with-ltrim-and-ucfirst/ Share on other sites More sharing options...
dooper3 Posted May 4, 2008 Share Posted May 4, 2008 You do it like this: $var=" name"; $var=ucfirst(ltrim($var)); whatever is inside brackets is always done first, so in this case the code strips the whitespace first, then takes the variable and capitalises the first letter afterwards. Link to comment https://forums.phpfreaks.com/topic/104051-help-with-ltrim-and-ucfirst/#findComment-532647 Share on other sites More sharing options...
gammaman Posted May 4, 2008 Author Share Posted May 4, 2008 Ok great but lets say $var is assigned to a $_POST can I just do ucfirst(ltrim($var)); or do I have to assign the $var=$_POST to another variable first and assigen that to $var1 ucfirst(ltrim($var1)); Link to comment https://forums.phpfreaks.com/topic/104051-help-with-ltrim-and-ucfirst/#findComment-532648 Share on other sites More sharing options...
AndyB Posted May 4, 2008 Share Posted May 4, 2008 $some_form_input = ucfirst(ltrim($_POST['some_form_input'])); Link to comment https://forums.phpfreaks.com/topic/104051-help-with-ltrim-and-ucfirst/#findComment-532652 Share on other sites More sharing options...
gammaman Posted May 4, 2008 Author Share Posted May 4, 2008 Thanks that helped out a lot. Link to comment https://forums.phpfreaks.com/topic/104051-help-with-ltrim-and-ucfirst/#findComment-532658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.