写一段由小到大排序的PHP代码
发表于:2022-11-24 10:23:32浏览:28次TAG:
以下是使用PHP编写一个数组由小到大排序的代码示例:
```
<?php
//定义一个数组
$array = array(7, 2, 5, 1, 3);
//使用sort()函数对数组按升序排序
sort($array);
//输出排序后的数组
print_r($array);
?>
```
在以上示例中,我们首先定义了一个包含5个数字的数组。使用sort()函数对该数组按升序进行了排序,最后使用print_r()函数输出排序后的数组。
基本
文件
流程
错误
SQL
调试
- 请求信息 : 2024-11-24 07:16:21 HTTP/1.1 GET : http://xn.iwdd.cn/home/article/detail/id/55.html
- 运行时间 : 0.080665s [ 吞吐率:12.40req/s ] 内存消耗:2,037.80kb 文件加载:151
- 查询信息 : 30 queries
- 缓存信息 : 16 reads,0 writes
- 会话信息 : SESSION_ID=a393ba643e704d0cfe3897e6b81adbe4
- CONNECT:[ UseTime:0.000477s ] mysql:host=127.0.0.1;port=3306;dbname=xn_iwdd_cn;charset=utf8mb4
- SHOW FULL COLUMNS FROM `cms_article` [ RunTime:0.000697s ]
- SELECT * FROM `cms_article` WHERE `id` = 55 LIMIT 1 [ RunTime:0.000384s ]
- SHOW FULL COLUMNS FROM `cms_article_keywords` [ RunTime:0.000419s ]
- SELECT `i`.`aid`,`i`.`keywords_id`,`k`.`title` FROM `cms_article_keywords` `i` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`i`.`keywords_id` WHERE `i`.`aid` = '55' AND `k`.`status` = '1' ORDER BY `i`.`create_time` ASC [ RunTime:0.000412s ]
- UPDATE `cms_article` SET `read` = `read` + 1 WHERE `id` = 55 [ RunTime:0.004503s ]
- SHOW FULL COLUMNS FROM `cms_article_cate` [ RunTime:0.000560s ]
- SELECT * FROM `cms_article_cate` ORDER BY `sort` DESC [ RunTime:0.000332s ]
- SELECT COUNT(*) AS think_count FROM `cms_article` WHERE `cate_id` = 1 AND `status` = 1 LIMIT 1 [ RunTime:0.002228s ]
- SELECT COUNT(*) AS think_count FROM `cms_article` WHERE `cate_id` = 2 AND `status` = 1 LIMIT 1 [ RunTime:0.002086s ]
- SELECT COUNT(*) AS think_count FROM `cms_article` WHERE `cate_id` = 3 AND `status` = 1 LIMIT 1 [ RunTime:0.001815s ]
- SELECT COUNT(*) AS think_count FROM `cms_article` WHERE `cate_id` = 4 AND `status` = 1 LIMIT 1 [ RunTime:0.001685s ]
- SELECT COUNT(*) AS think_count FROM `cms_article` WHERE `cate_id` = 5 AND `status` = 1 LIMIT 1 [ RunTime:0.001612s ]
- SELECT COUNT(*) AS think_count FROM `cms_article` WHERE `cate_id` = 6 AND `status` = 1 LIMIT 1 [ RunTime:0.001564s ]
- SELECT COUNT(*) AS think_count FROM `cms_article` WHERE `cate_id` = 7 AND `status` = 1 LIMIT 1 [ RunTime:0.001751s ]
- SELECT COUNT(*) AS think_count FROM `cms_article` WHERE `cate_id` = 8 AND `status` = 1 LIMIT 1 [ RunTime:0.001557s ]
- SHOW FULL COLUMNS FROM `cms_keywords` [ RunTime:0.000436s ]
- SELECT * FROM `cms_keywords` WHERE `status` = 1 ORDER BY rand() , id desc LIMIT 20 [ RunTime:0.000350s ]
- SELECT `a`.`id`,`a`.`title`,`a`.`thumb`,`a`.`create_time`,`a`.`read`,`a`.`desc`,`f`.`filepath` FROM `cms_article` `a` LEFT JOIN `cms_file` `f` ON `a`.`thumb`=`f`.`id` WHERE `a`.`status` = '1' ORDER BY rand() , a.id desc LIMIT 10 [ RunTime:0.013830s ]
- SELECT `k`.`id`,`k`.`title` FROM `cms_article_keywords` `a` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`a`.`keywords_id` WHERE `a`.`aid` = '2635' AND `k`.`status` = '1' LIMIT 4 [ RunTime:0.000410s ]
- SELECT `k`.`id`,`k`.`title` FROM `cms_article_keywords` `a` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`a`.`keywords_id` WHERE `a`.`aid` = '1878' AND `k`.`status` = '1' LIMIT 4 [ RunTime:0.000262s ]
- SELECT `k`.`id`,`k`.`title` FROM `cms_article_keywords` `a` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`a`.`keywords_id` WHERE `a`.`aid` = '2215' AND `k`.`status` = '1' LIMIT 4 [ RunTime:0.000238s ]
- SELECT `k`.`id`,`k`.`title` FROM `cms_article_keywords` `a` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`a`.`keywords_id` WHERE `a`.`aid` = '795' AND `k`.`status` = '1' LIMIT 4 [ RunTime:0.000246s ]
- SELECT `k`.`id`,`k`.`title` FROM `cms_article_keywords` `a` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`a`.`keywords_id` WHERE `a`.`aid` = '205' AND `k`.`status` = '1' LIMIT 4 [ RunTime:0.000215s ]
- SELECT `k`.`id`,`k`.`title` FROM `cms_article_keywords` `a` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`a`.`keywords_id` WHERE `a`.`aid` = '6' AND `k`.`status` = '1' LIMIT 4 [ RunTime:0.000238s ]
- SELECT `k`.`id`,`k`.`title` FROM `cms_article_keywords` `a` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`a`.`keywords_id` WHERE `a`.`aid` = '4316' AND `k`.`status` = '1' LIMIT 4 [ RunTime:0.000209s ]
- SELECT `k`.`id`,`k`.`title` FROM `cms_article_keywords` `a` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`a`.`keywords_id` WHERE `a`.`aid` = '3011' AND `k`.`status` = '1' LIMIT 4 [ RunTime:0.000210s ]
- SELECT `k`.`id`,`k`.`title` FROM `cms_article_keywords` `a` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`a`.`keywords_id` WHERE `a`.`aid` = '3343' AND `k`.`status` = '1' LIMIT 4 [ RunTime:0.000255s ]
- SELECT `k`.`id`,`k`.`title` FROM `cms_article_keywords` `a` LEFT JOIN `cms_keywords` `k` ON `k`.`id`=`a`.`keywords_id` WHERE `a`.`aid` = '1835' AND `k`.`status` = '1' LIMIT 4 [ RunTime:0.000219s ]
- SHOW FULL COLUMNS FROM `cms_user_log` [ RunTime:0.000511s ]
- INSERT INTO `cms_user_log` SET `uid` = 0 , `nickname` = '游客' , `type` = 'view' , `title` = '查看' , `content` = '游客在2024-11-24 07:16:21查看了写一段由小到大排序的PHP代码文章详情' , `param_id` = 55 , `param` = '[]' , `module` = 'home' , `controller` = 'article' , `function` = 'detail' , `ip` = '3.12.34.150' , `create_time` = 1732403781 [ RunTime:0.004427s ]
0.088164s