M
M
midarovrk2016-12-03 19:43:42
PHP
midarovrk, 2016-12-03 19:43:42

How to specify the number of characters in item(0)->nodeValue?

Hello, tell me, in the xml file there is such a value 8.154
Through php I get the value, but how to make it take only 3 characters? Like this 8.1
$rating->item(0)->nodeValue; // get value

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Barmunk, 2016-12-03
@midarovrk

round up
php.net/round
Returns a substring
php.net/manual/en/function.substr.php
rounding is better than string trimming.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question