You should probably save the data in a global, so you can call the function multiple times in the same PHP script.