Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP更新数组值问题_Php_Arrays - Fatal编程技术网

PHP更新数组值问题

PHP更新数组值问题,php,arrays,Php,Arrays,我这里有一个非常初级的问题——我试着在谷歌上搜索并阅读PHP.net教程,很明显,它似乎更新了一个数组,我没有任何运气 这是我的问题 在我的代码中有一行: $router = Router::get(array('appDirectory' => dirname(__FILE__).DIRECTORY_SEPARATOR)); 关于这一点,我想更新本节: (array('appDirectory' => dirname(__FILE__).DIRECTORY_SEPARATOR))

我这里有一个非常初级的问题——我试着在谷歌上搜索并阅读PHP.net教程,很明显,它似乎更新了一个数组,我没有任何运气

这是我的问题

在我的代码中有一行:

$router = Router::get(array('appDirectory' => dirname(__FILE__).DIRECTORY_SEPARATOR));
关于这一点,我想更新本节:

(array('appDirectory' => dirname(__FILE__).DIRECTORY_SEPARATOR))
其中带有var_转储,提供以下内容:

array(1) { ["appDirectory"]=> string(40) "/Applications/MAMP/htdocs/hockey/hockey/" }
我希望是:

array(1) { ["appDirectory"]=> string(40) "/Applications/MAMP/htdocs/hockey/hockey/SOMEOTHERADD" }
请帮忙


谢谢。

要更新示例中的阵列,只需执行以下操作

  $array["appDirectory"] = $array["appDirectory"] . 'attache-string';
 


这应该可以解决问题


希望答案清楚并且有帮助。

要更新示例中的数组,只需执行以下操作

  $array["appDirectory"] = $array["appDirectory"] . 'attache-string';
 
$array1 = array('appDirectory' => dirname(__FILE__).DIRECTORY_SEPARATOR);

//if you wish to update before assigning:
$array1['appDirector'] = "/Applications/MAMP/htdocs/hockey/hockey/SOMEOTHERADD";

$router = Router::get($array1);

//if after var $router is an array from your var_dump example

$router['appDirector'] = "/Applications/MAMP/htdocs/hockey/hockey/SOMEOTHERADD";

var_dump($router); //This should produce array(1) { ["appDirectory"]=> string(40) "/Applications/MAMP/htdocs/hockey/hockey/SOMEOTHERADD" }


这应该可以解决问题


希望答案清楚并且有帮助。

好吧,然后将
'SOMEOTHERADD'
连接到传递给方法的值的末尾……好吧,然后将
'SOMEOTHERADD'
连接到传递给方法的值的末尾…
$array1 = array('appDirectory' => dirname(__FILE__).DIRECTORY_SEPARATOR);

//if you wish to update before assigning:
$array1['appDirector'] = "/Applications/MAMP/htdocs/hockey/hockey/SOMEOTHERADD";

$router = Router::get($array1);

//if after var $router is an array from your var_dump example

$router['appDirector'] = "/Applications/MAMP/htdocs/hockey/hockey/SOMEOTHERADD";

var_dump($router); //This should produce array(1) { ["appDirectory"]=> string(40) "/Applications/MAMP/htdocs/hockey/hockey/SOMEOTHERADD" }