(PHP 8 >= 8.3.0)
stream_context_set_options — 指定されたコンテキストのオプションを設定する
contextオプションを適用するストリーム、またはコンテキストリソース。
options
       context に設定するオプション。
      
注意:
optionsは、$array['wrapper']['option'] = $valueのフォーマットからなる連想配列でなければいけません。ストリームオプションの一覧は コンテキストオプションとパラメータ を参照ください。
例1 stream_context_set_options() の例
<?php
$context = stream_context_create();
$options = [
    'http' => [
        'protocol_version' => 1.1,
        'user_agent' => 'PHPT Agent',
    ],
];
stream_context_set_options($context, $options);
var_dump(stream_context_get_options($context));
?>上の例の出力は以下となります。
array(1) {
  ["http"]=>
  array(2) {
    ["protocol_version"]=>
    float(1.1)
    ["user_agent"]=>
    string(10) "PHPT Agent"
  }
}
