public static function encode_attributes($attributes)
{
$return = array();
foreach ($attributes as $key => $value) {
$return[] = urlencode($key) . '=' . urlencode($value);
}
return join('&', $return);
}