Flat array to nested in php

Requirements = PHP 5.3

Usage:

Thanks! http://stackoverflow.com/a/27360654/1886270