www.webdeveloper.com
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
    Posts
    84

    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
    Location
    Ankh-Morpork
    Posts
    18,923
    "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

    eBookworm.us

  3. #3
    Join Date
    Mar 2010
    Posts
    2,803
    ..
    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