how to put javascript variable in php echo [closed]
I want to add JavaScript variable to php echo
arr[i]='<?php echo $winner[javascript variable]; ?>';
Thanks
Solution 1:
You can't.
- PHP runs on the server and outputs some text.
- The text is sent to the browser
- The browser interprets the text as HTML / JavaScript / etc
The PHP has finished running by the time the JavaScript is executed.
If you want to pass data back you need to make a new HTTP request and run a PHP script from scratch.