sprintf with dynamic number of elements



I'm looking for a way to pass a dynamic number of args to sprintf.

So instead of

$a = "a";
$b = "b";
$c = "c";
sprintf($format, $a, $b, $c)

one could

$args = array("a", "b", "c");
sprintf($format, $args)

It seems like sprintf should support this natively, but it doesn't.

Is there a way to accomplish this?


.



Relevant Pages

  • Re: passing a va_list to sprintf
    ... > sprintf(buf, format, args); ... > But I can't get sprintf to properly take the args I have given to f. ... What you want is vsprintf and not sprintf. ...
    (comp.lang.c)
  • [PATCH] vsprintf.c cleanups
    ... Make sprintf call vsnprintf directly ... int vsprintf(char *buf, const char *fmt, va_list args) ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • returning a formated string
    ... I'm making a function that returns a formated String. ... p.s. if I should be using sprintf or something else like that, ... msg.Format(fmt, args); ... return msg; ...
    (microsoft.public.vc.language)
  • Re: passing a va_list to sprintf
    ... > void f ... > sprintf(buf, format, args); ... > But I can't get sprintf to properly take the args I have given to f. ...
    (comp.lang.c)
  • RE: Command line args not passed message when debugging
    ... The message referenced in my original post indicates that args will not be ... But they are, once you change the security zone, as recommended by yourself, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vsnet.general)