12-13-2008, 01:00 AM
|
#4 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
If you're willing and/or able to use some of the SPL features then you code could be whittled down to something like the following (just an example off the top of my head).
PHP Code:
class Parameters extends ArrayObject {
public function __construct($string)
{
$string = str_replace(',', '&', $string);
parse_str($string, $data);
$this->exchangeArray($data);
}
}
$string = 'something=test,this=that';
$params = new Parameters($string);
// Can use array syntax, or offsetGet method
var_dump( $params['this'] );
|
|
|
|