Need opposite of array()

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi.  Relative php newbie but longtime coder in other langs.
Environment: PHP4.

Looking for a language construct or function that gives the opposite of


function xyz($fmt, $argsarray)
    // do something with each $argsarray

    $result = sprintf( $fmt, un_array( $argsarray ) );

    return $result;

Need to find something like "un_array" to produce a list of scalars from an
array so can be passed as arg list to sprintf and similar functions.  Does
it exist?  I've already thought of recursively building $fmt by picking off
first element of $argsarray, but looking for something cleaner and more


Re: Need opposite of array()

I'm not sure if this is exactly what you're looking for, but implode()
will give you back a delimitated string of all the elements of the
array. Check it out here: [ ].

Re: Need opposite of array()

comp.lang.php contained the following:

Quoted text here. Click to load it

Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs /

Re: Need opposite of array()

comp.lang.php wrote:

Quoted text here. Click to load it

  Sorry, don't think this quite exists as you want it.  You're asking to
take a semantic feature (arrays storing multiple values) and convert it to
a syntactic feature (multiple magically named variables separated by

  There is the extract() function, which is close, but still not quite what
you're asking for.

  what you want is:

  vsprint, or vprintf

  both of which take the list of arguments as arrays, not a variable list.

  good ruck!

I am not an ANGRY man.  Remove the rage from my email to reply.

Re: Need opposite of array()


Quoted text here. Click to load it


function xyz($fmt, $argsarray)
    array_unshift($argsarray, $fmt);
    $result = call_user_func_array('sprintf', $argsarray);
    return $result;

< Space: disk usage analysis tool

Site Timeline