I'm searching for a way to use named arguments for sprintf
or printf
.
Example:
sprintf(
'Last time logged in was %hours hours,
%minutes minutes, %seconds seconds ago'
,$hours,$minutes, $seconds
);
or via vsprintf
and an associative array.
I have found some coding examples here
function sprintfn ($format, array $args = array())
http://php.net/manual/de/function.sprintf.php
and here
function vnsprintf( $format, array $data)
http://php.net/manual/de/function.vsprintf.php
where people wrote their own solutions.
But my question is, is there maybe an standard PHP solution out there to achieve this or is there another way, maybe with a simple PHP templating provided by PEAR, that I can achieve this by sticking to standard PHP?
Thanks for any help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…