1. Home
  2. Car Demon Code Docs
  3. Display Filters
  4. cd_mileage_filter

cd_mileage_filter

This filter can be used to modify the numerical format of your vehicle’s mileage.

apply_filters( ‘cd_mileage_filter’, $mileage )

add_filter( 'cd_mileage_filter', 'my_mileage', 10, 1 );
function my_mileage( $mileage ) {

    $mileage = number_format( $mileage, 0, '', ',' );

    return $mileage;
}

In the above example we used the PHP number_format() function to add commas as the “thousands” separator and to make sure no decimal points are shown.

More info: number_format(number,decimals,decimalpoint,separator)

Learn all about the PHP number_format() function www.w3schoolds.com

Was this article helpful to you? Yes No

How can we help?