Research the Explode() function.
Basically you split your current variable into three different parts using the Explode() function delimited by a 'space'. Once done, whatever variable you split it into becomes a three variable array.
Put the arrays in whatever order you want and glue them back together. You will then have a new string.
So in other words, read up on how explode and arrays work and you should be able to solve your problem.