Remove if exists all character before _

I can’t get what you need to return. If you need an array, you can try this:

$result = array_map(function (string $item) {
    return preg_replace('.+_', '', $item);
}, explode(',', $categoriesInArticle));

also, you can implode(',', $result) to get string w/o _ sign.

Browse More Popular Posts

Leave a Comment