Results 1 to 3 of 3

Thread: Run a Function for Each Occurrence of a Substring Within a String

  1. #1
    Join Date
    Jan 2010

    Run a Function for Each Occurrence of a Substring Within a String

    I'm looking for the most efficient way of searching through a string, and for each occurrence of a substring, run a function on it. Similar to the array_filter() function for arrays, except it would be on a string. I suppose I could break up the string into an array of words, but I don't think that would be the most efficient method. Hoping somebody out there knows of a function I could use for that.

    For example:

    str_filter($search, $subject, $function_name);
    and it would run
    myFunction(&$value) { return TRUE; }

  2. #2
    Join Date
    Aug 2004
    "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

  3. #3
    Join Date
    Mar 2010
    Last edited by tirna; 03-18-2010 at 06:57 PM. Reason: Solution would not have worked

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

Recent Articles