Php Regex Replace Array Python Memory