I have a body of text that includes randomised numbers.
I make an array of the numbers, process them (look up relevant information to display based on each number) and then reinsert the changed array into the original text at the same locations I took the array from.
So far I am using preg_match_all to create the new array, then foreach for the process, then I insert these strings into a new array called $replacement.
So I have an array that I want to use to replace the strings in the original text. The problem is that I want the replacement calculated on the position value - regardless of what's in the array, string 1 matches string 1 by position in the array.
Difficult to explain. Here's an example.
Original text: Hello 1 Hello 2 Hello 3
original array {
[0] 1
[1] 2
[2] 3
}
replacement array {
[0] One
[1] Two
[2] Three
}
So when I do what I need to do, the original body text would look like:
Hello One Hello Two Hello Three
The catch is, I'd also want it to look like Hello One Hello Two Hello Three
even if the original array was:
original array {
[0] 1
[1] 1
[2] 1
}
replacement array {
[0] One
[1] Two
[2] Three
}
How could I do that?