2个回答
展开全部
1
<?php
$arr = [
['num'=>1,'name'=>'tom','sex'=>1,'age'=>16],
['num'=>2,'name'=>'peter','sex'=>1,'age'=>23],
['num'=>3,'name'=>'mary','sex'=>1,'age'=>27],
['num'=>4,'name'=>'john','sex'=>1,'age'=>19],
];
$arr = array_column($arr,null,'age');
ksort($arr);
2
<?php
$data = $_POST;
$is_login = false;
if(!empty($data)&& $data['account'] == 'admin' && $data['pwd'] == '1234' ){
$is_login = true;
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="" method="post">
<?php
if($is_login){
echo 'Admin登录成功';
}else{
echo "<label for=''>用户名</label><input type='text' name='account'>";
echo "<label for=''>密码</label><input type='password' name='pwd' id='' value=''>";
echo "<input type='submit'>";
}
?>
</form>
</body>
</html>
3
<?php
$arr = [
['num'=>1,'name'=>'tom','sex'=>1,'hobby'=>'篮球'],
['num'=>2,'name'=>'peter','sex'=>1,'hobby'=>'足球'],
['num'=>3,'name'=>'mary','sex'=>1,'hobby'=>'钢琴'],
['num'=>4,'name'=>'john','sex'=>1,'hobby'=>'画画'],
];
print_r($arr);
4
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file" >
<input type="submit">
</form>
</body>
</html>
<?php
if (isset($_FILES['file'])) {
$ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
if (!in_array($ext, ['rar', 'zip'])) {
return '只允许上传rar和zip文件';
}
$file_size = $_FILES['file']['size'];
if ($file_size > 2 * 1024 * 1024) {
return '不能上传大于2M的文件';
}
$uploaded_file = $_FILES['file']['tmp_name'];
$file_name = pathinfo($_FILES['file']['name'], PATHINFO_BASENAME);
$upload_path = './upload/';
//判断该文件夹是否存在
if (!is_dir($upload_path)) {
mkdir($upload_path, 0777, true);
}
if (move_uploaded_file($uploaded_file, $upload_path . '/' . $file_name)) {
return '上传成功';
} else {
return '上传失败,请重试';
}
}
<?php
$arr = [
['num'=>1,'name'=>'tom','sex'=>1,'age'=>16],
['num'=>2,'name'=>'peter','sex'=>1,'age'=>23],
['num'=>3,'name'=>'mary','sex'=>1,'age'=>27],
['num'=>4,'name'=>'john','sex'=>1,'age'=>19],
];
$arr = array_column($arr,null,'age');
ksort($arr);
2
<?php
$data = $_POST;
$is_login = false;
if(!empty($data)&& $data['account'] == 'admin' && $data['pwd'] == '1234' ){
$is_login = true;
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="" method="post">
<?php
if($is_login){
echo 'Admin登录成功';
}else{
echo "<label for=''>用户名</label><input type='text' name='account'>";
echo "<label for=''>密码</label><input type='password' name='pwd' id='' value=''>";
echo "<input type='submit'>";
}
?>
</form>
</body>
</html>
3
<?php
$arr = [
['num'=>1,'name'=>'tom','sex'=>1,'hobby'=>'篮球'],
['num'=>2,'name'=>'peter','sex'=>1,'hobby'=>'足球'],
['num'=>3,'name'=>'mary','sex'=>1,'hobby'=>'钢琴'],
['num'=>4,'name'=>'john','sex'=>1,'hobby'=>'画画'],
];
print_r($arr);
4
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file" >
<input type="submit">
</form>
</body>
</html>
<?php
if (isset($_FILES['file'])) {
$ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
if (!in_array($ext, ['rar', 'zip'])) {
return '只允许上传rar和zip文件';
}
$file_size = $_FILES['file']['size'];
if ($file_size > 2 * 1024 * 1024) {
return '不能上传大于2M的文件';
}
$uploaded_file = $_FILES['file']['tmp_name'];
$file_name = pathinfo($_FILES['file']['name'], PATHINFO_BASENAME);
$upload_path = './upload/';
//判断该文件夹是否存在
if (!is_dir($upload_path)) {
mkdir($upload_path, 0777, true);
}
if (move_uploaded_file($uploaded_file, $upload_path . '/' . $file_name)) {
return '上传成功';
} else {
return '上传失败,请重试';
}
}
追问
虽然昨晚已经做完了,但还是采纳采纳吧。嘿嘿
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询