There is a line of the form
3199996|Amazing Dubbing||3199114|AniDUB||3204688|AniLibria||3204934|AniMaunt||3198662|AnimeVost||3199009|AniPlay||3199879|AniRise||3198674|AniStar||3210309|Anything Group||3199048|KBK||3201994|KitsuneBox||3200688|Risens Team||3199154|SHIZA Project||3199180|TAKEOVER Project|||3206565|AniDUB||3214108|AniLibria||3204770|AnimeVost||3214571|AniRise||3204751|AniStar||3213831|Anything Group||3206322|KBK||3211200|KitsuneBox||3205028|Risens Team||3210273|SHIZA Project|||3216986|AniDUB||3218426|AniLibria||3214254|AnimeVost||3219614|AniRise||3214057|AniStar||3214746|Anything Group||3219664|KBK||3214608|Risens Team||3215849|SHIZA Project|||3218870|AnimeVost||3218862|AniStar||3219909|Anything Group||3218760|Risens Team All i can do with this porridge
$str = "3199996|Amazing Dubbing||3199114|AniDUB||3204688|AniLibria||3204934|AniMaunt||3198662|AnimeVost||3199009|AniPlay||3199879|AniRise||3198674|AniStar||3210309|Anything Group||3199048|KBK||3201994|KitsuneBox||3200688|Risens Team||3199154|SHIZA Project||3199180|TAKEOVER Project|||3206565|AniDUB||3214108|AniLibria||3204770|AnimeVost||3214571|AniRise||3204751|AniStar||3213831|Anything Group||3206322|KBK||3211200|KitsuneBox||3205028|Risens Team||3210273|SHIZA Project|||3216986|AniDUB||3218426|AniLibria||3214254|AnimeVost||3219614|AniRise||3214057|AniStar||3214746|Anything Group||3219664|KBK||3214608|Risens Team||3215849|SHIZA Project|||3218870|AnimeVost||3218862|AniStar||3219909|Anything Group||3218760|Risens Team"; $mas = explode("|||", $str); $str_result=""; foreach ($mas as $value) { $mas1 = explode("||", $value); foreach ($mas1 as $value1) { $mas2 = explode("|", $value1); $str_result .= $mas2[1]."-".$mas2[0]."<br>"; } } echo $str_result; Result of code execution
Amazing Dubbing-3199996 AniDUB-3199114 AniLibria-3204688 AniMaunt-3204934 AnimeVost-3198662 AniPlay-3199009 AniRise-3199879 AniStar-3198674 Anything Group-3210309 KBK-3199048 KitsuneBox-3201994 Risens Team-3200688 SHIZA Project-3199154 TAKEOVER Project-3199180 AniDUB-3206565 AniLibria-3214108 AnimeVost-3204770 AniRise-3214571 AniStar-3204751 Anything Group-3213831 KBK-3206322 KitsuneBox-3211200 Risens Team-3205028 SHIZA Project-3210273 AniDUB-3216986 AniLibria-3218426 AnimeVost-3214254 AniRise-3219614 AniStar-3214057 Anything Group-3214746 KBK-3219664 Risens Team-3214608 SHIZA Project-3215849 AnimeVost-3218870 AniStar-3218862 Anything Group-3219909 Risens Team-3218760 Task: convert a line from the original view to such
AnimeVost|3198662|3204770|3214254|3218870||AniStar|3198674|3204751|3214057|3218862||Anything Group|3210309|3213831|3214746|3219909||Risens Team|3200688|3205028|3214608|3218760||AniDUB|3199114|3206565|3216986||AniLibria|3204688|3214108|3218426||.....||Amazing Dubbing|3199996 AnimeVost, AniStar, etc. - these are groups of people, 3198662, 3204770, etc. - these are works of art created by these groups of people. I need to sort the line so as to assign the group all the id that belongs to it. And the group with more id goes first, then the one with less than the first, and so on. (descending count id)