I want the following output:-
About to deduct 50% of € 27.59 from your Top-Up account.
when I do something like this:-
Escape it with another %
:
$stringWithVariables = 'About to deduct 50%% of %s %s from your Top-Up account.';
What about this:
$variablesArray[0] = '%';
$variablesArray[1] = '€';
$variablesArray[2] = 27.59;
$stringWithVariables = 'About to deduct 50%s of %s %s from your Top-Up account.';
echo vsprintf($stringWithVariables, $variablesArray);
Just add your percent sign in your variables array
It is very easy.
Put another %
in front of the original %
to escape it.
For example,
$num=23;
printf("%%d of 23 = %d",$num);
Output:
%d of 23 = 23