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 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)); 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 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
Archived
This topic is now archived and is closed to further replies.