dongpao5127 2019-06-25 15:32
浏览 67

php natsort有2个数组

I have this code :

$values_total[]=$file;
$values_total_data[]=$cmd_[$n];

natsort($values_total);

The first array called $values_total[] is numeric and have the number of simple txt files (154512452.txt, etc), with information inside, in a single line, but this array have only numeric values.

The second array called $values_total_data[] have the data line for each file

If i want, i can use natsort for get natural order by the letters or numbers

The problem it´s in this case i use this code for create select as in this example :

print "<select>";
$n=0;
foreach($values_total_data as $vals)
{
print "<option value='".$vals."'>".$values_total_data[$n]."</option>";
$n++;
}
print "</select>";

But the problem it´s that natsort order files by his id numeric number, and i need the order it´s for words inside in each file for get in first the title start for "a" "b", etc, but in select the option value must be numeric, and this numbers are inside $values_total[]

And i don´t know how i can combinate this for order by text and no by id of each text file, regards .

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 python代码,帮调试
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条