$data=[];
$time=['5','10','20','30','60','120','180','240','300','360','420','480'];
$area=["北京","天津","河北","山西","辽宁","吉林","上海","江苏",    "浙江","安徽","福建","江西","山东","河南","湖北","湖南","广东",    "广西","海南","重庆","四川","贵州"];
$surname=['赵', '钱', '孙', '李', '周', '吴', '郑', '王', '冯', '陈', '楮', '卫', '蒋', '沈', '韩', '杨',
    '朱', '秦', '尤', '许', '何', '吕', '施', '张', '孔', '曹', '严', '华', '金', '魏', '陶', '姜',
    '戚', '谢', '邹', '喻', '柏', '水', '窦', '章', '云', '苏', '潘', '葛', '奚', '范', '彭', '郎',
    '鲁', '韦', '昌', '马', '苗', '凤', '花', '方', '俞', '任', '袁', '柳', '酆', '鲍', '史', '唐',
    '费', '廉', '岑', '薛', '雷', '贺', '倪', '汤', '滕', '殷', '罗', '毕', '郝', '邬', '安', '常',
    '乐', '于', '时', '傅', '皮', '卞', '齐', '康', '伍', '余', '元', '卜', '顾', '孟', '平', '黄',
    '和', '穆', '萧', '尹', '姚', '邵', '湛', '汪', '祁', '毛', '禹', '狄', '米', '贝', '明', '臧',
    '计', '伏', '成', '戴', '谈', '宋', '茅', '庞', '熊', '纪', '舒', '屈', '项', '祝', '董', '梁',
    '杜', '阮', '蓝', '闽', '席', '季', '麻', '强', '贾', '路', '娄', '危', '江', '童', '颜', '郭',
    '梅', '盛', '林', '刁', '锺', '徐', '丘', '骆', '高', '夏', '蔡', '田', '樊', '胡', '凌', '霍',
    '虞', '万', '支', '柯', '昝', '管', '卢', '莫', '经', '房', '裘', '缪', '干', '解', '应', '宗',
    '丁', '宣', '贲', '邓', '郁', '单', '杭', '洪', '包', '诸', '左', '石', '崔', '吉', '钮', '龚',
    '程', '嵇', '邢', '滑', '裴', '陆', '荣', '翁', '荀', '羊', '於', '惠', '甄', '麹', '家', '封',
    '芮', '羿', '储', '靳', '汲', '邴', '糜', '松', '井', '段', '富', '巫', '乌', '焦', '巴', '弓',
    '牧', '隗', '山', '谷', '车', '侯', '宓', '蓬', '全', '郗', '班', '仰', '秋', '仲', '伊', '宫',
    '宁', '仇', '栾', '暴', '甘', '斜', '厉', '戎', '祖', '武', '符', '刘', '景', '詹', '束', '龙',
    '叶', '幸', '司', '韶', '郜', '黎', '蓟', '薄', '印', '宿', '白', '怀', '蒲', '邰', '从', '鄂',
    '索', '咸', '籍', '赖', '卓', '蔺', '屠', '蒙', '池', '乔', '阴', '郁', '胥', '能', '苍', '双',
    '闻', '莘', '党', '翟', '谭', '贡', '劳', '逄', '姬', '申', '扶', '堵', '冉', '宰', '郦', '雍',
    '郤', '璩', '桑', '桂', '濮', '牛', '寿', '通', '边', '扈', '燕', '冀', '郏', '浦', '尚', '农',
    '温', '别', '庄', '晏', '柴', '瞿', '阎', '充', '慕', '连', '茹', '习', '宦', '艾', '鱼', '容'];
$sex=["先生","女士"];
$pet=["西施犬","阿拉斯加",    "布偶猫",    "加菲猫",    "褴褛猫",    "巴厘猫",    "波斯猫",    "暹罗猫",    "藏獒","西高地","小鹿犬","雪纳瑞",    "泰迪熊",    "史宾格",    "沙皮犬",    "松狮",    "萨摩耶",    "秋田犬",    "牛头梗",    "腊肠",    "卡斯罗",    "柯基犬",    "京巴",    "吉娃娃",    "金毛",    "蝴蝶犬",    "哈士奇",    "古牧",    "杜宾犬",    "大白熊",    "柴犬",    "巴哥",    "比熊",    "博美犬"];

for($i=0;$i<$num;$i++){
    $data[$i]["time"]=$time[rand(0,sizeof($time)-1)];
    $data[$i]["area"]=$area[rand(0,sizeof($area)-1)];
    $data[$i]["surname"]=$surname[rand(0,sizeof($surname)-1)];
    $data[$i]["sex"]=$sex[rand(0,sizeof($sex)-1)];
    $data[$i]["pet"]=$pet[rand(0,sizeof($pet)-1)];
    $data[$i]["price"]=rand(200,10000);
}

//根据time对数组进行排序
array_multisort(array_column($data,"time"),SORT_ASC,$data);

var_dump($data);

array(10) { 
[0]=> array(6) { ["time"]=> string(1) "5" ["area"]=> string(6) "四川" ["surname"]=> string(3) "林" ["sex"]=> string(6) "先生" ["pet"]=> string(9) "吉娃娃" ["price"]=> int(6778) } 
[1]=> array(6) { ["time"]=> string(1) "5" ["area"]=> string(6) "山西" ["surname"]=> string(3) "盛" ["sex"]=> string(6) "女士" ["pet"]=> string(9) "哈士奇" ["price"]=> int(7852) } 
[2]=> array(6) { ["time"]=> string(2) "10" ["area"]=> string(6) "江西" ["surname"]=> string(3) "幸" ["sex"]=> string(6) "先生" ["pet"]=> string(6) "古牧" ["price"]=> int(6222) } 
[3]=> array(6) { ["time"]=> string(2) "10" ["area"]=> string(6) "辽宁" ["surname"]=> string(3) "柯" ["sex"]=> string(6) "女士" ["pet"]=> string(9) "蝴蝶犬" ["price"]=> int(4115) } 
[4]=> array(6) { ["time"]=> string(3) "120" ["area"]=> string(6) "上海" ["surname"]=> string(3) "贲" ["sex"]=> string(6) "先生" ["pet"]=> string(6) "巴哥" ["price"]=> int(2372) } 
[5]=> array(6) { ["time"]=> string(3) "240" ["area"]=> string(6) "海南" ["surname"]=> string(3) "酆" ["sex"]=> string(6) "先生" ["pet"]=> string(6) "金毛" ["price"]=> int(8777) } 
[6]=> array(6) { ["time"]=> string(3) "300" ["area"]=> string(6) "海南" ["surname"]=> string(3) "和" ["sex"]=> string(6) "先生" ["pet"]=> string(9) "巴厘猫" ["price"]=> int(4330) } 
[7]=> array(6) { ["time"]=> string(3) "360" ["area"]=> string(6) "山东" ["surname"]=> string(3) "楮" ["sex"]=> string(6) "先生" ["pet"]=> string(9) "西施犬" ["price"]=> int(6549) } 
[8]=> array(6) { ["time"]=> string(3) "360" ["area"]=> string(6) "河北" ["surname"]=> string(3) "费" ["sex"]=> string(6) "先生" ["pet"]=> string(6) "松狮" ["price"]=> int(9395) } 
[9]=> array(6) { ["time"]=> string(3) "420" ["area"]=> string(6) "安徽" ["surname"]=> string(3) "经" ["sex"]=> string(6) "女士" ["pet"]=> string(6) "古牧" ["price"]=> int(1927) } 
} 

标签: none

添加新评论