Hello! Ok so what I am trying to do is parse a string say

fearhomefear

so anyway, I have an array with the words found in that string ( array (fear, home))

is there any way to find the all matches of each word in the string without using a memory intensive function like preg_match_all to find all occurences of a substring (so for the string "fearhomefear" i would need to find the words 'fear', 'home', and 'fear') - since the needle is not a regular expression but a plain string?

    Nevermind people I found what im looking for
    http://us2.php.net/manual/en/function.str-replace.php#68951

    function replaceOnce($search, $replace, $content){

    $pos = strpos($content, $search);
    if ($pos === false) { return $content; }
    else { return substr($content, 0, $pos) . $replace . substr($content, $pos+strlen($search)); }

    }

      If you just want to know the number of times it's found, look into using [man]substr_count/man.

        Write a Reply...