<?php
// Turn your junk into an array
$includes = array(
"inc/related-portfolio-aaa.php",
"inc/related-portfolio-bbb.php",
"inc/related-portfolio-ccc.php",
"inc/related-portfolio-bbb.php"
);
// Loop that shit
foreach($includes as $inc){
$include = true;
// Check if the current filename is in the format you mentioned
//if(strpos(__FILE__, "-project.php") !== false){
// Get the prefix of the current filename
$prefix = explode("-", __FILE__)[0];
// Get the suffix of the include
$suffix = explode(".", explode("-", $inc)[2])[0];
// Check if it matches
//if($prefix === $suffix) $include = false;
echo $prefix." - ".$suffix."\n";
}
//if($include) include $inc;
}