Added a wrapper around array_replace so that the functionality works in PHP5.2