149 posts
  • Microlancer Beta Tester
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
s4nji says


Here, I made one with preg_match_all, pretty much worked :)
Sanji thats pretty awesome work, may i use your code too. thankyou :)
Yes, you may use it, you’re welcome :D
5070 posts
  • Australia
  • Bought between 100 and 499 items
  • Community Superstar
  • Exclusive Author
  • Has been a member for 3-4 years
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
Australia says

What is code, for adding a var and echoing it out using the code you made please, just as a sample.

149 posts
  • Microlancer Beta Tester
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
s4nji says

What is code, for adding a var and echoing it out using the code you made please, just as a sample.
echo denominate($_GET['n']);
Why do you ask?
5070 posts
  • Australia
  • Bought between 100 and 499 items
  • Community Superstar
  • Exclusive Author
  • Has been a member for 3-4 years
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
Australia says


What is code, for adding a var and echoing it out using the code you made please, just as a sample.
echo denominate($_GET['n']);
Why do you ask?

I must be having a brain fart ( its late and been a long day )

<?php
    $numb ='125678767';
    function denominate($number) {
    // Define the denominators
    $value = array( 'thousand','million','billion','trillion' );
    // Use preg_match_all to gather datas
    $pattern = '/(\d+),(.+)/';
    preg_match_all( $pattern, $number, $result );
    // Get the first block of numbers
    $main = $result[1][0];
    // Get and specify the text for the value denominator
    $sub = substr_count( $result[2][0], ',' );
    $sub = $value[$sub];
    // Get the 'numbers behind the comma'
    $float = str_replace ( ',', '', $result[2][0] );
    $float = round( $float, 2 - strlen( $float ) );
    $float = substr( $float, 0, 2 );
    // Output
    return "$main,$float $sub";
}
?>
<?php echo denominate($_GET['numb']); ?>
149 posts
  • Microlancer Beta Tester
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
s4nji says
$number = '12,345,678,901';

function denominate($number) {
    // Define the denominators
    $value = array( 'thousand','million','billion','trillion' );
    // Use preg_match_all to gather datas
    $pattern = '/(\d+),(.+)/';
    preg_match_all( $pattern, $number, $result );
    // Get the first block of numbers
    $main = $result[1][0];
    // Get and specify the text for the value denominator
    $sub = substr_count( $result[2][0], ',' );
    $sub = $value[$sub];
    // Get the 'numbers behind the comma'
    $float = str_replace ( ',', '', $result[2][0] );
    $float = round( $float, 2 - strlen( $float ) );
    $float = substr( $float, 0, 2 );
    // Output
    return "$main,$float $sub";
}

echo denominate($number);

You don’t know how to use functions? You are having a brain fart, or… :grin:
By the way, the inputted numbers must be separated with comma manually, like the numbers you wrote at your first post.

5070 posts
  • Australia
  • Bought between 100 and 499 items
  • Community Superstar
  • Exclusive Author
  • Has been a member for 3-4 years
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
Australia says

Thanks, I never mentioned I knew what i was doing ! lol

639 posts
  • Exclusive Author
  • Sold between 100 and 1 000 dollars
  • Bought between 10 and 49 items
  • Has been a member for 1-2 years
  • Haiti
Crakken says

Here, I made one with preg_match_all, pretty much worked :)

I’m not a big fan of preg_match but it works out really great. Good job. :)

by
by
by
by
by
by