Вопрос

I've tried using the 'number_format' in the code below but did't return the intended result. This counter works, all I want to do is simply show a dot or comma after the thousands change. So instead of 1000 that shows now, to show 1.000.

There's also a related txt file in the same folder where the count data is stored-just saying.

<?php 

$fp = fopen("counters/counterlog.txt", "r"); 

$count = fread($fp, 1024); 

fclose($fp); 

$count = $count + 1; 

echo "<p>Pageview: " . $count . "</p>"; 

$fp = fopen("counters/counterlog.txt", "w"); 

fwrite($fp, $count); 

fclose($fp); 

?>
Это было полезно?

Решение 2

Preety straight forward answer for you...

<?php
$fp = fopen("counters/counterlog.txt", "r"); 
$count = fread($fp, 1024); 
fclose($fp); 
$count = $count + 1; 
echo "<p>Pageview: " . number_format($count) . "</p>"; // <===
$fp = fopen("counters/counterlog.txt", "w"); 
fwrite($fp, $count); 
fclose($fp); 
?>

Другие советы

in short http://php.net/manual/en/function.number-format.php

in long:

echo "<p>Pageview: " . number_format($count) . "</p>";

Try number_format()

echo "<p>Pageview: " . number_format($count,3,'.') . "</p>";
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top