Since the JavaScript runs on the client long after (in computer time) the php has finished running on the server, PHP has no way of knowing at that time what the JavaScript will decide the value of its variables will be.
Depending on what it is exactly that you want to do, you'll either need to restructure the PHP code, or perhaps consider an "AJAX" implementation in your JavaScript code to call a server-side PHP script to get the desired data at run-time (JavaScript run-time, that is).