- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$text = "Hello!! I'm Sajjad Hossain Sagor. It's 2023. w00t :D \ud83e\udd17";
$pattern = "/(?:\\\\u[a-f0-9]+)+|'[stdm]|'[rv]e|'ll| ?\p{L}+| ?\p{N}+| ?(?!\\\\u[a-f0-9]+\b)[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+/";
preg_match_all(
$pattern,
$text,
$matches
);
var_dump($matches[0]);