eazyGen Posted February 22, 2012 Share Posted February 22, 2012 Hi guys, I would normally research this myself, but I am in a hurry just now. My question is - how would I take a string like: "Customer Name" or "Product Cost Price" and produce a result where all upper case letters are made lower case and all spaces replaced by under-scores. Like this: "Customer Name" would become "customer_name", and "Product Cost Price" would become "product_cost_price" Many thanks for any swift help, S Quote Link to comment https://forums.phpfreaks.com/topic/257523-quick-and-dirty-regex-question/ Share on other sites More sharing options...
Adam Posted February 22, 2012 Share Posted February 22, 2012 If they are the only requirements, you can just use string functions to do this: $str = strtolower(str_replace(' ', '_', $str)); Quote Link to comment https://forums.phpfreaks.com/topic/257523-quick-and-dirty-regex-question/#findComment-1319938 Share on other sites More sharing options...
eazyGen Posted February 24, 2012 Author Share Posted February 24, 2012 If they are the only requirements, you can just use string functions to do this: $str = strtolower(str_replace(' ', '_', $str)); Many thanks, Sorry to appear lazy, but I was in a mad rush. S Quote Link to comment https://forums.phpfreaks.com/topic/257523-quick-and-dirty-regex-question/#findComment-1320643 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.