简体   繁体   中英

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. 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. Thanks

It was so simple. Add php echoed values to an array using split function then use sort function.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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