Modified the queryToArray function to pass in a callback function.

Added a callback function to the queryToArray function which if present
will get each query element passed to it before it is added to the
array. The developer can modify the item how ever they wish in the
callback function.