Jump to content

Using number_format() with Text Include


phpBeginner06

Recommended Posts

Is there a way to use number_format() with a PHP Include that is a text file? I made a script, but it does not echo that right results.

[code]<?php

$somenumber=include("01-25-2007.txt");
$formatted=number_format($somenumber);

echo "$formatted";

?>[/code]


The text file "01-25-2007.txt" contains the number "1000". The script should echo a number like "1,000"; but instead it's echo looks like this: "10001".

Is it even possible to use number_format() with a text inlude? If so, what is the best way to go about doing it?
Link to comment
Share on other sites

That's not how you use the include() function.

What does the included file contain?

You can do something like this:

File test_include.php
[code]<?php
$somenumber = 1000;
?>[/code]

Main script:
[code]<?php
include('test_include.php');
$formatted = format_number($somenumber);
echo $formatted;
?>[/code]

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.