我遇到问题,我需要一个查询来连接表与两个数据库和每个不同网络的数据库。网络192.168.1.1中的 ABC数据库示例和网络192.168.1.2中的数据库EFD 我试过并问别人,他们说这是不可能的。 那么还有其他方法可以加入数组PHP代码吗? 所以这样的例子:
数据库ABC table glass 中的数组是:
Array
(
[0] => Array
(
[id] => 1
[name] => Glass one
)
[1] => Array
(
[id] => 2
[name] => Glass two
)
[2] => Array
(
[id] => 3
[name] => Glass three
)
)
数据库EFD表格价格中的数组是:
Array
(
[0] => Array
(
[id] => 1
[glass_id] => 1
[price] => $50
)
[1] => Array
(
[id] => 2
[glass_id] => 2
[price] => $30
)
)
然后我想在数组2中将基于 id 的两个数组与数组2中的 glass_id 组合在一起。然后我想得到如下结果:
Array
(
[0] => Array
(
[name] => Glass one
[price] => $50
)
[1] => Array
(
[name] => Glass two
[price] => $30
)
)
答案 0 :(得分:-1)
<?php
$array1 = array("make","model","color","year");
$array2 = array("Jeep","Liberty","Black","2005");
$newArray = array_combine($array1, $array2);
foreach ($newArray as $key => $value) {
echo "$key - <strong>$value</strong> <br />";
}
试试这个。