Heim >Backend-Entwicklung >PHP-Tutorial >php将一个数组按另一个数组的规则替换键值并获取其值转为字符串
现在有两个数组
$arr1=array("q" => "1","w" => "2","e" => "3");$arr2=array([0] => "你",[1] => "我",[2] => "他");
$arr = array("q" => "你","w" => "我","e" => "他");//然后需要只获取这个数组的值 转为字符串 用逗号隔开 $str ='你,我,他';
$arr1=array("q" => "1","w" => "2","e" => "3");$arr2=array(0 => "你",1 => "我",2 => "他");$arr3 = array_combine(array_keys($arr1), $arr2);print_r($arr3);echo join(',', $arr3);
Array( [q] => 你 [w] => 我 [e] => 他)你,我,他
$arr1=array("q" => "1","w" => "2","e" => "3");$arr2=array(0 => "你",1 => "我",2 => "他");$arr3 = array_combine(array_keys($arr1), $arr2);print_r($arr3);echo join(',', $arr3);
Array( [q] => 你 [w] => 我 [e] => 他)你,我,他
Array ( [0] => Array ( [is_notice] => 5 ) [1] => Array ( [is_notice] => 16 ) )
你这可是二维数组呀
Array ( [0] => Array ( [is_notice] => 5 ) [1] => Array ( [is_notice] => 16 ) )
你这可是二维数组呀
这样吗?
$arr1 = array( array('is_notice'=>3), array('is_notice'=>2), array('is_notice'=>1));$arr2 = array( 0 => '系统通知', 1 => '材料通过', 2 => '审核失败', 3 => '额度更新');$arr3 = array();foreach($arr1 as $k=>$v){ $arr3[]['is_notice'] = $arr2[$v['is_notice']];}print_r($arr3);
Array ( [0] => Array ( [is_notice] => 5 ) [1] => Array ( [is_notice] => 16 ) )
你这可是二维数组呀