I was wondering if there was any possible way to keep track of JavaScript variables within a for loop inside PHP.
I definitely know that this is not good design. However, I'm trying to hack some existing code. If I am able to make this work, I may not have to dump the existing code...
Thanks you guys. Any hacks, tips, tricks will work!!
Example:
//JavaScript for loop for (var i = 0; i <4; ++i) { //Echo the JavaScript variable "i", the iteration of the loop <?php echo /*JavaScript var i */ ; ?>}
EDIT: More background info
I'm working on a project where the data is supplied through XML and the API is written in PHP and returns an PHP array. The front end is designed whilst using a lot of JavaScript. I'm going to need to populate JavaScript fields with fields from my PHP object through multiple iterations. Hence, the PHP inside the JavaScript for loop.
Neither the front end nor the back end is written by me, mind you. :P