Well if you want to replace the space in ME 323 with an underscore, use str_replace like weedpacket suggested.
$new_variable = str_replace(" ", "_", $code);
Here's the link to str_replace() at php.net. That page will give you full documentation on using str_replace() including its parameters and user comments. When in doubt on how to use a function, check php.net 😉
Cgraz