Hello again,
I have got question - how make str_replace replace only one (first) element, so f.e:
i like pie i like pie i like pie i like pie
Than
str_replace("pie", "apple", $all);
and result
i like apple i like pie i like pie i like pie
Use preg_replace instead.
$getall = preg_split('!<tid="[0-9]+"/>!', $contents, -1, PREG_SPLIT_NO_EMPTY); for($i = 0; $i < count($getall); $i++) { $contents = preg_replace("/".$getall[$i]."/","<id=\"$i\"/>",$contents); $translater = $getall[$i]."<>$i\n".$translater; }
I used method which was posted here earlier. $getall[$i] - keeps sentences or words on my page - Why i this not working (it does not change any element).
What exactly are you trying to do now?
Uh, this whole thing (whatever it is) is starting to look weird. I'm having a hard time thinking of a way to justify the existence of that "$translater" string, and that's just the start.
I have to ask the same question as laserlight.