Php Change Array Keys Recursive Algorithm