从2个数组填充数组键值

时间:2018-06-26 10:04:33

标签: php arrays

我从该代码中得到2个数组:

$default = '2000,1000,750';
$defaultRule = 'min-width:2000,min-width:1000,min-width:750';
$arr_responsive = explode(',' , $default);
$arr_responsiveRule = explode(',' , $defaultRule);

现在我想获得一个唯一的数组,其键为= $ arr_sensitive,值= $ arr_sensitiveRule

获取:

$array(
    '2000'  => 'min-width:2000',
    '1000'  => 'min-width:1000',
    '750'  => 'min-width:750'
)

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

$result = array_combine(
    $arr_responsive,     // these are keys
    $arr_responsiveRule  // these are values
)