What are alternative methods to using number_format() for handling decimal point formatting in PHP when outputting data to a CSV file?

When outputting data to a CSV file in PHP, the number_format() function may not always be the best choice for formatting decimal points. Alternative methods include using sprintf() or number_format() with str_replace() to customize the formatting of decimal points.

// Using sprintf() to format decimal points
$value = 1234.5678;
$formatted_value = sprintf("%.2f", $value);

// Using number_format() with str_replace() to customize decimal point formatting
$value = 1234.5678;
$formatted_value = number_format($value, 2, '.', '');
$formatted_value = str_replace('.', ',', $formatted_value);