Last Updated: February 20, 2016
·
2.966K
· thebrainroom

Changing the number format of a field in Drupal 7

When printing raw data from a node you may need to insert a decimal place to split a number up. For example, a value of 12000 is printed out but you want 12,000. You can use number_format to do this:

<?php print (number_format($node->field_number['und'][0]['value'])); ?>

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside