Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.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/0/backbone.js/2.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_Associative Array - Fatal编程技术网

Php 使用同一数组中的关联数组值

Php 使用同一数组中的关联数组值,php,arrays,associative-array,Php,Arrays,Associative Array,我试图从同一数组中访问关联数组的键和值。如果我的数组中有3对。我可以在第三个另一个中使用某物和其他的值吗 $gar = array("something" => "something value", "other" => "other value", "another" => something . other ); 这种想法是,另一个人的价值将是“其他价值的东西” 这可能吗?有没有办法完成同样的事情?像

我试图从同一数组中访问关联数组的键和值。如果我的数组中有3对。我可以在第三个
另一个
中使用
某物
其他
的值吗

$gar = array("something" => "something value", 
             "other" => "other value", 
             "another" => something . other 
       );
这种想法是,另一个人的价值将是“其他价值的东西”


这可能吗?有没有办法完成同样的事情?

像这样的事情怎么样

$gar = array("something" => "something value", 
         "other" => "other value"
   );

$gar["another"] = $gar["something"] . $gar["other"];

像这样的怎么样

$gar = array("something" => "something value", 
         "other" => "other value"
   );

$gar["another"] = $gar["something"] . $gar["other"];

如果您在多行上使用它,则应该可以如下所示:

$gar = array();
$gar["something"] = "something value";
$gar["other"] = "other value";
$gar["another"] = $gar["something"].$gar["other"];

您甚至可以将上面的序列放入一个循环中。

如果您在多行中使用它,则应该可以:

$gar = array();
$gar["something"] = "something value";
$gar["other"] = "other value";
$gar["another"] = $gar["something"].$gar["other"];

你甚至可以把上面的序列放在一个循环中。

我的问题也谈到了类似的问题。希望有帮助!:)

我的问题也谈到了类似的问题。希望有帮助!:)

我之所以选择这个,是因为它看起来有点干净,虽然两者都很好用。我之所以选择这个,是因为它看起来有点干净,虽然两者都很好用。