Results 1 to 2 of 2

Thread: Is there a better way to do this?

  1. #1
    Join Date
    Feb 2012
    Pensacola, FL

    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.

    PHP Code:
    //This makes $col = "overviewContentEditable";  
    $col str_replace(" ","",lcfirst(ucwords(str_replace("_"," ","overview_content_editable")))); 
    It does exactly what I need it too, just wondering if there was a faster way.

  2. #2
    Join Date
    Aug 2004
    Maybe (untested):
    PHP Code:
    $result preg_replace_callback(
    $matches) {
    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.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center