Hi

I have this function that implodes an array with keys:

function implode_with_keys( $glue, $array )
{
$output = array();

foreach( $array as $key => $item )
	$output[] = $key . "=" . $item;

return implode( $glue, $output );

}

Now I need a function that explodes the string to an array with keys but I dont know how:

function explode_with_keys( $glue, $string )
{
????
}

Is there some expert php developer that want to help me?

    my attempt:

    ...
    // glue must not be "="
    $output = array();
    $array = explode($glue,$string);
    for ($i=0; $i < sizeof($array); $i++)
    {
      list($key,$value) = explode("=", $array[$i]);
      $output[$key] = $value;
    }
    return $value;
    ...

    untested

      It worked like a charm except for one simple error - return $output offcourse 🙂

      Thankyou very much!

        Write a Reply...