So Apparently there is no built-in function that does that, so I wrote this function:
<?php
$UNICODE_CATEGORIES = [
"Cc",
"Cf",
"Cs",
"Co",
"Cn",
"Lm",
"Mn",
"Mc",
"Me",
"No",
"Zs",
"Zl" ,
"Zp",
"Pc",
"Pd",
"Ps" ,
"Pe" ,
"Pi" ,
"Pf" ,
"Po" ,
"Sm",
"Sc",
"Sk",
"So",
"Zs",
"Zl",
"Zp"
];
function uni_category($char, $UNICODE_CATEGORIES) {
foreach ($UNICODE_CATEGORIES as $category) {
if (preg_match('/\p{'.$category.'}/', $char))
return $category;
}
return null;
}
// call the function
print uni_category('-', $UNICODE_CATEGORIES); // it returns Pd
This code works for me, I hope it helps someby in the future :).