hmm... let me try to follow this
[font=monospace]$k2=mysql_real_escape_string($k);[/font]
escaped version of the array key.
[font=monospace]if($k!=$k2) unset($x[$k]);[/font]
compares escaped key to original key; unsets original array index if they don't match.
[font=monospace]$x[$k2]=check($v); [/font]
then recurses on the value and sets a new item in the array using the escaped key and value.
if the original key and the escaped key were equal (i.e.: the key didn't need to be escaped), then we've got the same index again ($k == $k2) with an escaped (possibly different) value.
if the original key did need to be escaped, then the (original|escaped)value is now stored under a new key - meaning the script probably won't be able to find it.
right?
SO...
I'm with Weedpacket on the "why?" issue.