CodeIgniter Forums
[ASK] How to change capitalize to lowercase and replace spacing with underscores - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: [ASK] How to change capitalize to lowercase and replace spacing with underscores (/thread-31498.html)



[ASK] How to change capitalize to lowercase and replace spacing with underscores - El Forum - 06-22-2010

[eluser]senz[/eluser]
Hi all,
I wanna ask something, how to change capitalize to lowercase and how to replace spacing with underscore?... Because i wanna change the title of my article into database and convert them. Ex : My New Article -> change to -> my_new_article.

Is there any function in codeigniter and how to implement into controller?


[ASK] How to change capitalize to lowercase and replace spacing with underscores - El Forum - 06-22-2010

[eluser]sharpe[/eluser]
Plain old php
Code:
strtolower(str_replace(" ","_",$str))



[ASK] How to change capitalize to lowercase and replace spacing with underscores - El Forum - 06-22-2010

[eluser]Derek Allard[/eluser]
Sharpe has a good solution, but you might also want to look at url_title(), which is my preferred approach.

http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html


[ASK] How to change capitalize to lowercase and replace spacing with underscores - El Forum - 06-22-2010

[eluser]senz[/eluser]
[quote author="Derek Allard" date="1277215336"]Sharpe has a good solution, but you might also want to look at url_title(), which is my preferred approach.

http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html[/quote]

I just read the URL Helper as you recomended and finally i can solved my problem after read the url_title() at URL Helper Guide.
Thanks Derek Smile