I found this function which finds data between two strings of text, html or whatever.
How can it be changed so it will find all occurrences? Every data between every
I needed to find all these occurences between specific first and last tag and change them somehow and get back changed string.
So I added this small code to raina77ow approach after the function.
$sample = 'One aaa TwoTwo Three Four aaaaa Five';
$sample_temp = getContents($sample, '', '');
$i = 1;
foreach($sample_temp as $value) {
$value2 = $value.'-'.$i; //there you can change the variable
$sample=str_replace(''.$value.'',$value2,$sample);
$i = ++$i;
}
echo $sample;
Now output sample has deleted tags and all strings between them has added number like this:
One-1 aaa TwoTwo-2 Three Four-3 aaaaa Five-4
But you can do whatever else with them. Maybe could be helpful for someone.