There are different ways, but it’s necessary to proceed from how different input data variations can be. The first thing that suggests itself is regular expressions, despite the fact that I am far from being a big fan of them:
preg_match('/(.*)\s\(([^()]+)\)$/', 'AK-47 | Красная линия (Factory New)', $matches); print_r($matches);
Or in this way:
$result = preg_split('/[()]/', 'AK-47 | Красная линия (Factory New)', -1, PREG_SPLIT_NO_EMPTY); print_r($result);
You can do without them, provided that the format of the lines will be exactly as you showed in the example. Those. split the string by the opening bracket, if you are sure that it will always be singular:
$result = array_map(function($a){ return trim($a, ' ()'); }, explode('(', 'AK-47 | Красная линия (Factory New)')); print_r($result);
Here is another option:
$str = 'AK-47 | Красная линия (Factory New)'; $bracket_pos = strpos($str, '('); echo substr($str, 0, $bracket_pos); echo trim(substr($str, $bracket_pos+1), ')');