Reputation: 1108
I am using PHP 5.6.22 and Apache 2.4.18. I have a $_SERVER
variable that I want to set to be a nested array.
To clarify, at the beginning of my PHP script, I want $_SERVER['key']
to be set to a two-level array as shown below:
$_SERVER['key'] = array('index' => array('sub_index' => 'some_value'))
Is this possible? Thanks in advance for your help.
Upvotes: 0
Views: 1199
Reputation: 56537
I've seen PUTENV
and GETENV
using json_***
functions, like:
$my_array= array( 'a'=>14, 'b'=>5);
PUTENV("my_namee=".json_encode($my_array));
.....
$var = json_decode(GETENV("my_namee"));
Upvotes: 0
Reputation: 785866
Create a file called myenv.php
with this code:
<?php
$_SERVER['key'] = array('index' => array('sub_index' => 'some_value'));
?>
Then add this line in your site root .htaccess:
php_value auto_prepend_file myenv.php
Now this data will be populated in $_SERVER
before loading of any .php
file.
Read more about auto_prepend_file
Upvotes: 1