Answer the question
In order to leave comments, you need to log in
How to cut string in php?
There are lines with news titles (video films), the line obtained from the {title} tag consists of the
name of the film (one or several words), the year (not always) and the type of rip (it is not difficult to make a list (WEB-DLRip, WEBRip-AVC, etc.). etc.)) now I need to cut everything that is after a year, that is, a certain array with the detection of occurrences of the rip type, a
few examples as is
The Hobbit: The Battle of the Five Armies (2014) DVDScr | CAMRip
Leviathan (2014) WEBRip-AVC
The Equalizer (2014) BDRip by HQ-ViDEO | License
The Hobbit: The Battle of the Five Armies (2014)
Leviathan (2014)
The Equalizer (2014)
Answer the question
In order to leave comments, you need to log in
preg_replace('/^(.*?)\s+(?:DVDScr|CAMRip|WEBRip|BDRip).*$/isu', '$1', $text);
$text = 'Великий уравнитель / The Equalizer (2014) BDRip от HQ-ViDEO | Лицензия';
var_dump(preg_replace('/^(.*?)\s+(?:DVDScr|CAMRip|WEBRip|BDRip).*$/isu', '$1', $text));die;
string(58) "Великий уравнитель / The Equalizer (2014)"
I did this (only the Russian name + year was needed) I pull out the
name to the special character (, / , etc.
I pull out the year separately. Then I output the already assembled one.
An example here is tracker.ru/search?q=%D0%B1%D0% BE%D0%B9
There
are a lot of movies that are grouped on the fly on the battle request.
so far only one idea comes to mind
$str = "Хоббит: Битва пяти воинств / The Hobbit: The Battle of the Five Armies (2014) DVDScr | CAMRip";
$pm = array();
preg_match('/\([0-9]{4}\)/', $str, $pm);
$ps = preg_split('/\([0-9]{4}\)/', $str);
$name = $ps[0].$pm[0];
echo $name;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question