0
Follows code:
<?
$url="url_aqui";
$result = file_get_contents($url);
?>
The variable $result
returns the value exactly this way: document.write('11,90');
I need to take only the value that is between the quotation marks, in case: 11,90
What condition could I use to do this?
Updated code:
$valor_mensal="url_monthly";
$valor_trimestral="url_quarterly";
$valor_semestral="url_semiannually";
$valor_anual="url_annually";
$b_mensal = file_get_contents($valor_mensal);
$b_trimestral = file_get_contents($valor_trimestral);
$b_semestral = file_get_contents($valor_semestral);
$b_anual = file_get_contents($valor_anual);
$primeiroCaractere_b_mensal = strpos($b_mensal, "'");
$primeiroCaractere_b_trimestral = strpos($b_trimestral, "'");
$primeiroCaractere_b_semestral = strpos($b_semestral, "'");
$primeiroCaractere_b_anual = strpos($b_anual, "'");
$basico_mensal = substr($b_mensal, $primeiroCaractere_b_mensal+1, -3);
$basico_trimestral = substr($b_trimestral, $primeiroCaractere_b_trimestral+1, -3);
$basico_semestral = substr($b_semestral, $primeiroCaractere_b_semestral+1, -3);
$basico_anual = substr($b_anual, $primeiroCaractere_b_anual+1, -3);
The URL is composed this way:
https://dominio.com/feeds/productsinfo.php?pid=3&get=price&billingcycle=monthly https://dominio.com/feeds/productsinfo.php?pid=3&get=price&billingcycle=quarterly https://dominio.com/feeds/productsinfo.php?pid=3&get=price&billingcycle=semiannually https://dominio.com/feeds/productsinfo.php?pid=3&get=price&billingcycle=annually
What if the value is 111.90 or 1.111.90? It will not always be the same value there.
– Wendler
The last parameter, when negative, will always count from the end of the string. Then it removes the last three characters, which will always be the same
');
– João Pedro Henrique
Very good, it worked.. But it was very extensive code, can you help me simplify the code if possible? Because there are several plans I will need to make. I updated the question with the updated code.
– Wendler
You can create a function that will return this value. I will update the answer
– João Pedro Henrique
Thank you very much. I added more details, how is the URL.
– Wendler