I think you're missing what he said. It's replacing the last item before the first item.

$replacex(1234,234,u,123,z)

You would expect that to replace the 234 first since it's first in your list and then when it got to the 123, there wouldn't be a match.

Another odd thing about it is that $replacex(1234,234,u,123,z,12,x) also returns z4. So it isn't reading the matches backwards and it isn't checking "1" then "12" then "123" or whatever. And both of these return the same thing:

$replacex(1234,234,u,123,z)
$replacex(1234,123,z,234,u)

That means you have no ability to get 1u.