zoukankan      html  css  js  c++  java
  • array_random 从一个数组中随机去几个,可以保持原数组顺序

    array_random 从一个数组中随机去几个,可以保持原数组顺序

    一、总结

    一句话总结:

    也就是array_random 的结果数组不会被打乱
    //从推荐课程列表中随机选出 $recommend_lesson_num 个
    //计算总课程数量
    $now_lesson_num=count($lessons);
    if($now_lesson_num>=$recommend_lesson_num){
        $lessons=array_random($lessons,$recommend_lesson_num);
    }else{
        $lessons=array_random($lessons,$now_lesson_num);
    }

    二、array_random 从一个数组中随机去几个,可以保持原数组顺序

    博客对应课程的视频位置:

    //从推荐课程列表中随机选出 $recommend_lesson_num 个
    //计算总课程数量
    $now_lesson_num=count($lessons);
    if($now_lesson_num>=$recommend_lesson_num){
        $lessons=array_random($lessons,$recommend_lesson_num);
    }else{
        $lessons=array_random($lessons,$now_lesson_num);
    }

     
  • 相关阅读:
    django的模板层
    django的视图层
    django的路由层
    web应用与http协议
    索引
    pymysql模块的使用
    多表查询
    单表查询
    数据的增删改
    自定义form组件
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/12628268.html
Copyright © 2011-2022 走看看