i want change one word from some of the same words with respect to the position of (the first second or third)
example :
$string = "He had had to have had it.";
echo preg_replace('/had/', 'SSS', $string, 1);
output :
He SSS had to have had it.
i want
-->: He SSS had to have had it
Or : He had SSS to have had it
Or : He had had to have SSS it
in the case of (my syntax), 'had' is replaced is the first.
if you give me idea, i want syntax should not be reading from the right or left, because it must be ensured where the sequence is replaced from the same word (replace words in a certain order, if I had the same 5 words, then I can easily replace the third word, etc) , what "preg_replace" can do it ? or any idea ?