如何在PHP中使用array_combine组合数组?

时间:2016-04-18 15:52:48

标签: php arrays php-5.3

我有以下数组

Array
(
    [country] => Array
        (
            [0] => AF
            [1] => BS
            [2] => BR
            [3] => GB
            [4] => US
        )

    [url] => Array
        (
            [0] => http://mu.com
            [1] => http://gov.com
            [2] => http://brazil.com
            [3] => http://uk.com
            [4] => http://usa.com
        )

)
Array=Array

Array值来自html表单Post方法,服务器端代码在这里

<?php 

$link[]=$_POST['url'];
$nation[] = $_POST['country'];
print_r($_POST);

$c=array_combine($link, $nation);
    foreach ($c as $link => $nation) {
        echo $link ."=".$nation;
    }
?>

我想使用array_combine和foreach循环显示以下格式,但我得到了Array = Array而不是结果。

http://mu.com = AF
http://gov.com = BS
http://Brazil.com = BR

请指导我这样做的正确方法

0 个答案:

没有答案