It’s likely not being output in the exact same format. What’s the result of your print_r?
If the output was the same, it would work the same as when we manually input the numbers.
If the output is multidimensional, has keys and values etc.. it won’t work. It just needs to be a simple array of values: https://developer.wordpress.org/reference/classes/wp_query/#post-page-parameters