(ideone)[http://ideone.com/efT0tD] with same code as [gist](https://gist.github.com/endJunction/6305964)