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;
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.