我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

随机排序php数组

I am getting an array of 25 items from a database using SQL. I want to take 16 of the items and random to use. I thought if I could randomly sort the array I could then take the first 16 items.

Is there a way to randomly sort an array in php, or perform an SQL SELECT that returns to results in a random order?

You can do this in SQL:

<your select here>
order by rand()
limit 16;

近期文章

  • 意外的$结束。 [重复]
  • PHP私有变量问题
  • php strpos offset输出不同
  • 将值附加到现有会话Laravel 5
  • PHP json_decode返回数组和数字键
  • 查找给定数字的最接近的数字总和
  • 正则表达式 - 简单的电话号码验证
  • 如何在php中优化这个短脚本 - 工资计算
  • 如何显示下拉选定的值
  • 如何从同一个列和表中搜索两个元值
  • Java,Javascript和PHP之间的差异,用于格式化相同的UNIX时间戳
  • 警告:strpos()最多需要3个参数,在第9行的page.php中给出23个[关闭]
  • 在Wordpress中添加Javascript - 使用wp_enqueue_script()函数.php
  • 使用Silex框架开发rest api
  • 只有当另一个字段为空或null时,mysql才会从行中删除
  • 在数组的每个索引中拆分字符串的第一部分并保留字符串的其余部分
  • PHP:HTML链接中的php变量(<a>)
  • HTML PHP表单帖子显示空白?
  • 如何在选择查询中获取行号
  • 字符串数组的限制? [重复]

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华