Is there a better way to do this?
I dont see myself using this elsewhere in the application so I don't want to make it a stand alone function. I feel like there is probably a preg_replace that would do what I want more efficiently.
It does exactly what I need it too, just wondering if there was a faster way.
//This makes $col = "overviewContentEditable";
$col = str_replace(" ","",lcfirst(ucwords(str_replace("_"," ","overview_content_editable"))));
As to whether that's actually more efficient processing-wise, you'd have to do some metering to find out. (Regex functions in general tend to be less efficient than comparable built-in string functions, but in a more complex case like this, the only way to tell would be to try it and measure it.
$result = preg_replace_callback(
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)