I have this code which works how I want it but im not sure what is happening.
Can someone explain what is happening which each character.
Changing different parts of the expression to a different colour will also help.

PHP Code:
Say the word is 'replace'
It results in this:

Thanks in advance.