I've got 4 PHP variables, and I have 1 Javascript variable with the name of one of those 4 PHP variables, how can reference it?
$p1 = ...
$p2 = ...
$p3 = ...
$p4 = ...
<script>
var myoption = 'p1';
var myarray = <?= $p1 ?>;
console.log(myarray);
</script>
In this case instead of setting myarray to $p1, I want to do it with myoption, once myoption can be p2 or p3
myoptionvary? Please edit your question to show more specifics.