I have the following sequence of numbers.
$str = '11 10 9 8 7 6 5 4 3 2 1 13 12';
How can I turn the above portion into this.
13 12 11 10 9 8 7 6 5 4 3 2 1
I have been messing around with this.
$str = $numbers;
$stringParts = str_split($str);
rsort($stringParts);
But the above only returns this when imploded.
11 10 9 8 7 6 5 4 3 2 1 31 21
Here's how I am gathering the numbers.
$categories = get_the_category();
$category_id = $categories[0]->cat_ID;
$catquery = new WP_Query( 'cat='.$category_id.'&posts_per_page=-1000' );
while($catquery->have_posts()) : $catquery->the_post();
$numbers = strip_tags( get_the_term_list( get_the_ID(), 'SECONDID', '', ', ', '' ) );
$str = $numbers;
$stringParts = str_split($str);
rsort($stringParts);
echo implode('', $stringParts);
This is taking the numbers randomly from WordPress custom taxonomy field, and not just placed into a string.
Screenshot edit because people don't like to believe.