0

我遇到了问题,我需要一个查询来将表与两个数据库和每个不同网络的数据库连接起来。网络 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
        )

)

然后我想将上面基于数组一中的id的两个数组与数组二中的glass_id结合起来。然后我想得到如下结果:

Array
(
    [0] => Array
        (
            [name] => Glass one
            [price] => $50
        )

    [1] => Array
        (
            [name] => Glass two
            [price] => $30
        )

)
4

1 回答 1

-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 />"; 
  }

试试这个。

于 2013-09-26T08:10:04.197 回答