I’m looking for the exact Javascript equivalent of php:
$tags = preg_split('/+/', $_GET['q'], NULL, PREG_SPLIT_NO_EMPTY);
$p = array_unique(array_map('strtolower', $tags));
sort($p);
It’s almost done
var queryString = decodeURIComponent(location.search.substring(1)).toLowerCase();
var key = queryString.split('&')[0].split('=');
if (key.length > 1){ //q should be the only query key
var tags = key[1].split(/\+/g);
// make tags values unique, non-empty and ordered alphabetically
}
but I’m looking for 3 things that are make tags values unique, non-empty and ordered alphabetically, it’s done easily in php, I hope there are such solutions in JavaScript.
You can find it on phpjs project:
Code:
split: (explodedependency)array_unique