Please see my code below, I am trying to put a function containing an if statement within str_replace, however, it is not injecting it into the script, thank you in advance for your help. Basically I need to replace [price] in the string with this if statement.
function price(){
if ($_SESSION['vat'] == "ex"){
echo('£'.$row_products['price'].'Ex. VAT');
} ?>
<?php if ($_SESSION['vat'] == "inc"){
$total_price = $row_products['price'] *= (1 + $VATrate / 100);
echo('£');
printf("%.2f", $total_price);
echo('Inc. VAT');
}
}
$main_description = str_replace('[price]', price(), $row_products['description']);