Phil Sturgeon's Blog: PHP Format abstraction with a simple class
Note: This article was originally published at PHPDeveloper on 14 February 2011.
Convert between Array, Object, JSON, XML, CSV and Serialized data and back again easily. I'll add a few more types like YAML when I can be arsed to work out PECL for MAMP.
There's a code snippet in his post showing the conversion of an array to JSON then to XML then back to an array. The code is pretty simple to follow with "to" and "from" methods for each format making it simple to extend for your own uses.