[man]htmlentities()[/man] would probably be what you need....
consquently had you posted more information, like the code you were trying to use this with that was returning a bad result/no result/an error, you probably would have been helped by now...