/ Published in: PHP

Simple function to create a params list type.
Example:
$array = array('first'=>'The first one','second'=>'The second one');
$string = parse_params($array);
//output first=the first one;second=the second one
$string = 'first=the first one;second=the second one';
$array = read_params($string);
//output array('first'=>'The first one','second'=>'The second one')
Example:
$array = array('first'=>'The first one','second'=>'The second one');
$string = parse_params($array);
//output first=the first one;second=the second one
$string = 'first=the first one;second=the second one';
$array = read_params($string);
//output array('first'=>'The first one','second'=>'The second one')
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function read_params($params) { foreach($params as $param) { $pa[$p[0]] = $p[1]; } return $params; } function parse_params($params,$gop=false) { foreach($params as $k=>$v){ $d[] = ($gop ? '{'.$k.'='.$v.'}' : $k.'='.$v); } } }
URL: www.censmedia.nl
Comments
