PHP POST请求特殊字符

I'm trying to send a special character, such as ñ, through a POST request in PHP. When I do it, it comes out as ñ, what is wrong and how do I fix it?

I'm sending and receiving the post request in PHP, here is what I use to send it:

$url = '<url>';
$data = array('key' => 'ñ');

$options = array(
    'http' => array(
        'header'  => "Content-type: application/x-www-form-urlencoded
",
        'method'  => 'POST',
        'content' => http_build_query($data)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

echo $result;

Thanks in advance!

Try using this:

$data = array('key' => urlencode('ñ'));

And in the $url file:

$_POST['key']=urldecode($_POST['key']);

This is how I use to send special characters in GET and POST method with ajax, it must work for php too.