rewrote PHP version to use associative array