php 数组 array_intersect_key() array_unique()移除重复

时间:2021-08-10 16:50:58
<?php
// array_unique($array) 去除重复
// array_unshif()向数组的顶部追加函数
// array_shif($a,"ss")向数组的顶部删除函数,返回删除的数
//array_pop($array);删除数组最后一个元素
//array_values($array) 得到数组的数值
// rtrim($a,",")删除右边多的逗号 echo "<pre>";
function dump($arrx){
print_r($arrx); }
/*
$arr6e = array("aa012" =>"苹果","d02" =>"雪莉","Aa03" =>"葡萄","Aa103" =>"葡萄"); $shop=array_unique($arr6a);
if ( array_shift($arr6a)){
echo "删除成功";
} //echo $arr8; array_unshift($arr6a, "lls"); dump($arr6a);*/ $arr6a = array("苹果","雪莉","葡萄");
//array_pop($arr6a);
$lemon = array("name" =>"lemon","sex" =>"man","age" =>"24","msn" =>"134545");
$keys = array_keys($lemon);
$names = array_values($lemon);
foreach ($keys as $k){
$key.="'".$k."',";
}
foreach ($names as $n){
$name.="'".$n."',";
}
$key=rtrim($key,",");
$name= rtrim($name,",");
//echo"name:".$key."<br>"."$name";
$sql="INSERT INTO db_user ({$key}) VALUES ({$name})";
echo $sql; ?>