title: How do I get all environment variables as an array in PHP?
body: <p>Title says it. I want to use this with <a href="https://www.php.net/manual/en/function.proc-open.php" rel="noreferrer">proc_open</a>, to append some variables to the current environment.</p>
  
  <pre><code>$current_env = get_all_env_vars_magically();
  $env = array_merge($current_env, $new_vars);
  $ph = proc_open($command, array(1 =&gt; array('pipe', 'w')), 
      $pipes, dirname(__FILE__), $env);
  </code></pre>
  
  <p>Edit: <code>$_ENV</code> is empty/not populated by default. <code>$_SERVER</code> contains so much more than env vars.</p>