简体   繁体   English

在PHP中从mysql订购数据时排除报价

[英]Exclude quotation while ordering data from mysql in php

Hi I have a php select statement that extracts everything from database and orders by starting letter of string. 嗨,我有一个php select语句,它通过字符串首字母来提取数据库和命令中的所有内容。 It takes quotations into account which i don't want. 它考虑了我不想要的报价。 I want it to look at the next character after quotes and order it accordingly. 我希望它查看引号后的下一个字符并相应地对其进行排序。 I'm Open to JS solutions as long as they don't remove the quotes. 我愿意接受JS解决方案,只要它们不删除引号即可。 Thanks 谢谢

It was so simple. 很简单。 Add php echoed values to an array using split function then use sort function. 使用split函数将php echo值添加到数组,然后使用sort函数。

array.sort(function mysortfunction(a,b) {
  a = a.text.replace(/"/g,'');
  b = b.text.replace(/"/g,'');

  return (a < b ? -1 : 1);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM