Answer the question
In order to leave comments, you need to log in
How to cut a string in php?
There are lines with movie titles,
some 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
Leviathan the
Great Equalizer
Answer the question
In order to leave comments, you need to log in
Well, for your specific case:
$row="Слуга народа (1 сезон: 1-24 серия из 24) (2015)";
if(!($str=strpos($row, "/"))) $str=strpos($row, "(");
echo $row=substr($row, 0, $str);
As an option:
$array = [
'Слуга народа (1 сезон: 1-24 серия из 24) (2015)',
'Хоббит: Битва пяти воинств / The Hobbit: The Battle of the Five Armies (2014) DVDScr | CAMRip',
'Левиафан (2014) WEBRip-AVC'
];
echo "<pre>";
$delimeters = ['/', '('];
foreach ($array as $str) {
foreach ($delimeters as $delimeter) {
if ($position = strpos($str, $delimeter)) {
echo substr($str, 0, $position) . "\n";
break;
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question