John Davidson

php - Echo each $value and $variable in span

0 comments
Message:


the context



I would like to output my snippet this way


Price : 2,330 $


what I want to do is give a class and surround price and currency by span like that


$value = <span class="price"> number_format(floatval($value), 0 ) </span> . <span class="currency"> $variable = get_field('currency', 'option')</span>; 

but it doesn't work like that...how to make html and give a css class inside my php snippet ?


to be able to css them individually


how to do it with my snippet inside $value = ?


add_filter('acf/format_value/name=price', 'acf_number_comma_decimal_for_currency_field', 20, 3);

function acf_number_comma_decimal_for_currency_field($value, $post_id, $field) {
if(empty($value)) { return 'Price: Contact US'; }
$value = number_format(floatval($value), 0 ) . $variable = get_field('currency', 'option');
return $value;
}

add_filter('acf/format_value/name=surface', 'acf_number_comma_decimal_for_surface_field', 20, 3);

function acf_number_comma_decimal_for_surface_field($value, $post_id, $field) {
if (get_field('$value')) { $value = number_format(floatval($value), 0) . $variable = get_field('symbol', 'option');}
return $value;
}


My Answer:
2,330;

echo "Price : $value $";

Rate this post

5 of 5 based on 3812 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us