1.把字符串 made_in_china转换成 MadeInChina, wel_come_gxr 转换成 WelComeGxr.
$str="made_in_china";
function change($str){
$tmp= explode('_',$str);
for($i=0;$i<count($tmp);$i++){
$tmp[$i]=str_replace($tmp[$i][0],strtoupper($tmp[$i][0]),$tmp[$i]);
}
$t= implode('',$tmp);
return $t;
}
echo change($str);
2.把数组 $first = array(10,9,8,7,6,7) 和 $second = array(8,5,4,3,2,10)合并成一个数组$third,从小到大排序,并踢除相同的值。
$arr1=array(10,9,8,7,6,7);
$arr2=array(8,5,4,3,2,10);
$arr3=array_merge($arr1,$arr2);
$arr3=array_unique($arr3);
sort($arr3);
var_dump($arr3);
3.(javascript试题)有一组数据, one,two,three,其对应的值分别是10,11,“DJFKAJKJFKDFKDK…….此处省略1万一个字母”,如何用ajax传递到服务器(可用jquery方法)?
<script type='text/javascript' charset='utf-8'>
var array=['one','two','three','AAAAAAA.......'];
var data='content='+array.join(',');
$.ajax({
url:'地址',
type:'post',
data:data,
success:function(data){
}
});
</script>
4.(可用mysql和php混合实现),有一张用户表user(假设有500万数据),包含姓名,性别,生日,所在省份,为user表添加字段并标明数据类型。
1.)统计生日在2016-1-1 – 2016-2-2之间的用户数(包含2016-1-1和2016-2-2)。
2.)请统计每个省份的用户数量。
Create table table_gql(
Id int unsigned primary key auto_increment,
Username varchar(50) not null default '',
birthday date,
pro_id int unsigned not null default 0
)engine=innodb default charset=utf8;
1.)
alter table table_gql add index province(pro_id);
alter table table_gql add index birthday(birthday);
2.)
select count(*) from table_gql where birthday ='2016-1-1' and birthday='2016-2-2';
3.)
select count(*) from table_gql group by pro_id;