I want the following output:-
About to deduct 50% of € 27.59 from your Top-Up account.
when I do something like this:-
$variablesArray[0] = '€';
$variablesArray[1] = 27.59;
$stringWithVariables = 'About to deduct 50% of %s %s from your Top-Up account.';
echo vsprintf($stringWithVariables, $variablesArray);
But it gives me this error vsprintf() [function.vsprintf]: Too few arguments in ... because it considers the % in 50% also for replacement. How do I escape it?
escapeorescapingin bothphp.net/printfandphp.net/vsprintfboth does not show the answer immediately. When I search for%%it shows the answer in php.net/printf but I didn't know about%%!!! Did you search for the answer there before downvoting?vsprintfbelongs in the same family of functions asprintf. The correct documentation to find the format, though, is php.net/sprintf. Both pages even point to it: "See sprintf() for a description of format." Didn't you at least click it?With printf() and sprintf() functions, escape character is not backslash '\' but rather '%'.What is there to downvote here? It was just not that obvious to me as it was to you. If you find a duplicate question you can better write the link. But I am sure many will find this question helpful. But you won't accept that and you will still say something, I know.