K
K
Kirill Abdulov2020-04-25 18:58:54
PHP
Kirill Abdulov, 2020-04-25 18:58:54

How to round to two decimal places?

require_once 'phpquery.php';
  function get_price($url) {
    $html = file_get_contents($url);
    $doc = phpQuery::newDocument($html);
    $price = $doc->find('/* Иду до числа типа float, вот до такого 74,5995*/')->text();

    return (float) (round($price, 2));
  }
        echo get_price(/* Туть юрл */);


The returned number is a floating point number, and when it is returned I round it to 2 decimal places, but it is output as an integer.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question