From the data you showed, I can't tell what the actual use case is. however, there are several ways to get data from the server to the client (php to js, or backend to front-end, whatever you want to call it).
Usually you want to get the data using AJAX from pure data endpoints (URLS that only deliver the raw data)
This requires that you have a good understanding of how you want to create your information architecture.
Of course, this is overkill for a simple testing-around project. However, if you have multiple situations like this, you should start thinking about a centralized approach to retrieving, fetching and using data.
PHP enables many front-end developers to also take care about the backend templates. And thus, also take care about the data that comes with it. If you are responsible for both front, and back-end but have little understanding of the underlying system, you are most often doomed to get stuck in this process of passing data from server to client.
If you have the freedom to create your own API, I recommend to get started with ProcessWire for PHP (I created a test API based on it).