user2797134
user2797134

Reputation: 83

Split emojis’s string in PHP

I have a string:

$string = '😂🧜‍♂️';

And i want to split in:

$array = ['1F602', '1F9DCU-200D-2642-FE0F'];

How can i do it?

I have already try to use some functions but they doesn’t works because they doesn’t split properly emojis with more then one unicode.

Thank you in advance!

Upvotes: 2

Views: 662

Answers (1)

drkostas
drkostas

Reputation: 527

I was about to write the code for splitting emojis using an emoji-unicode dictionary but fortunately the code already exists.

This repo contains everything you need.

You can either use it directly or explore the code and take what you want.

Upvotes: 2

Related Questions