New to PHP so apologies in advance for the simple question.
I have a Javascript file (.js). which contains a list of values. i.e.
var item1 = 1.00;
var item2 = 25.00;
var item2 = 35.00;
Can can i use PHP to read this file and import the data in an array with values.
item1 = 1.00
item2 = 25.00
item2 = 35.00
and then I would like to be able to GET the PHP script with.
xyz.com/file.php?id=item1.
and be able to send back the associated value.
I now this is simple, but i am having very little success as to where to start. I reviewed https://www.php.net/manual/en/function.parse-ini-file.php. but I think it it needs the file to be read to have .ini extension which is not an option in my situation.
Any help,guidance,advise would be greatly appreciated.
Thank you in advance.
var item1 = 1.00;
var item2 = 25.00;
var item3 = 35.00;
let array = [];
array.push(item1)
array.push(item2)
array.push(item3)
let inputs = ``;
for(let i = 0; i <= array.length - 1; i++){
inputs += `
<div>
<input type="text" value='${array[i]}' />
</div>
`
}
document.getElementById("inputs-here").innerHTML = inputs;
<form method="post" action="your-route-here">
<div id="inputs-here"></div>
<input type="submit" value="submit" />
</form>
and after you can capture it in PHP, just try this and you can take from there
print_r($_POST)
You can also create these inputs as "hidden" and submit without button, using JavaScript automatically, but that's different subject.