Inconsistent behavior from number_format

Seems like the function you using is the the_field function from of ACF which is a function that outputs a string so the formatting number_formatt dosent effect the output.

This code:

 <?php echo number_format(the_field('price')); ?>

The echo does not really print anything, the function the_fields prints the output, that’s the reason the number_format function doesn’t have any effect on the output.

Try getting the field via different function get_field for example, or you could add the the function the_fields a $format_value argument like you could see in the docs .

This should work:

<?php echo number_format( get_field( 'price' ) ); ?>