Convert a name=value pairs string into array





11
Date Submitted Fri. Nov. 25th, 2005 7:58 PM
Revision 1 of 2
Helper poncho
Tags Array | Name | PHP | String | Value
Comments 3 comments
Convert a name=value pairs string into array
function pairstr2Arr ($str) {
    $elems = explode(',', $str);
    foreach( $elems as $elem => $val ) {
        $val = trim($val);
        $arr[] = explode('=', $val);
        $arr[$elem][0] = trim($arr[$elem][0]);
        $arr[$elem][1] = trim($arr[$elem][1]);
    }
    return $arr;
}

Mark Thompson

www.defaultstate.com/
Perfecting the art of breaking stuff!

Comments

Comments ...
Fri. Jul. 21st, 2006 12:48 AM    Beginner hello2usir
  Comments Beat me
Tue. Aug. 8th, 2006 8:29 PM    Beginner schmalls
Comments Example of input and output
Thu. Feb. 16th, 2006 7:00 AM    Beginner nev3rm0re

Voting