I need to convert some functions in PHP to JS, so I'll need to put all these functions inside a .js file.
I currently have the following in PHP:
$basicoUS_mensal=processaValor("url_aqui");
function processaValor($url) {
$result = file_get_contents($url);
$aspas = strpos($result, "'");
$valor = substr($result, $aspas+1, -3);
return $valor;
}
The URL returns as follows, so it has the function that takes only the value: document.write ('11, 90 ');
On the PHP page I was using the following script, part of it follows:
var plano_basicoUS = {
1: parseFloat(<? echo str_replace(',', '.', $basicoUS_mensal); ?>),
};
As not .js does not work PHP, I need to change that part to work in the .js file.
In the above case the value of var plano_basicoUS[1]
would be: 11.90
What alternative could I use?