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条回答

    报告相同问题?

    悬赏问题

    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算