Support

Account

Home Forums Backend Issues (wp-admin) number_format() expects parameter 1 to be float, string given Reply To: number_format() expects parameter 1 to be float, string given

  • Thanks as always John!

    Found out my default code is working I was just loading another block which did not have an solution if empty/switch for number_fromat(); which was causing the issue.

    Below works and the same using if only, but I stick with switch easier to structure if you don’t see something I’m missing or wrong doing?

    <?php
    	$value = get_field('data_value');
    
    				switch ($value){
    					case null:
    						echo '-';
    						break;
    					default:
    						echo esc_attr($pre_value) . number_format($value);
    				}
    ?>
    <?php 
    	$value = get_field('data_value');
    
    					if ($value):
    						echo esc_attr($pre_value) . number_format($value);
    					else: echo '-';
    				endif;
    ?>