After foreach ($infolist as $info) {
, add:
if ($info['rating'] == 'XXX') { continue; };
This will skip over the XXX-rated titles before attempting to output anything for them, which should have the effect you desire.
Question
I've tried and it doesn't seem to work. Any help would be greatly appreciated.
CODE:
foreach (glob('mov/Alene*.mov') as $filename){
$theData = file_get_contents($filename) or die("Unable to retrieve file data");
}
$string = $theData;
$titles = explode("\n", $string);
function getInfo($string){
$Ratings = ['G', 'PG', 'PG-13', 'R', 'NR', 'XXX'];
$split = preg_split("/\"(.+)\"/", $string, 0, PREG_SPLIT_DELIM_CAPTURE);
if(count($split) == 3){
preg_match("/(".implode("|", $Ratings).")\s/", $split[0], $matches);
$rating = $matches[0];
return ["title" => $split[1], "rating" => $rating];
}
return false;
}
$infolist = array();
foreach($titles as $title){
$info = getInfo($title);
if($info !== false){
$infolist[] = $info;
}
}
usort($infolist, "infosort");
function infosort($lhs,$rhs) {
return strcmp($lhs['rating'], $rhs['rating']);
}
foreach ($infolist as $info) {
echo "<div style ='margin-bottom: 3px; text-align: center;
font:13px Verdana,tahoma,sans-serif;color:green;'>
{$info["title"]} : {$info["rating"]}</div>";
}
//------------------LOGO---------------------//
echo "<div style='text-align:center; margin-top: 20px;'><img src='imgs/shclogo.png'
alt='Logo' width='200' height='133'/></div>";
//-------------------------------------------//
?>
I've tried adding:
if($info["rating"]!=="XXX")//foreach $infolist as $info...
I've also tried adding that in the source where preg_match is but that didn't work either. It all still displays the "XXX" titles.
I just need to figure out how to ignore the XXX titles and display everything else.
The output originally looks like this...
(HD) Safe House : R
(HD) Wanderlust : R
(HD) Machine Gun Preacher : R
(HD) Silent House : R
(HD) Seeking Justice : R
Adult title 1 : XXX
Adult title 2 : XXX
Adult title 3 : XXX
Adult title 4 : XXX
There are many more XXX titles, but I can't display them all. Any help and you'd be my life saver.
Solution
After foreach ($infolist as $info) {
, add:
if ($info['rating'] == 'XXX') { continue; };
This will skip over the XXX-rated titles before attempting to output anything for them, which should have the effect you desire.