With PHP-MapScript, you can get all layer names as an array.
You can make an array of the layers wish to enable, using the layer name.
This is not the most elegant solution, and there is likely a better method supported through the API, but quick and dirty you can just step through the entire list of layers and disable them and only enable the ones you want.
Step through both arrays, disabling all layer, but enabling if there is a match in the array containing the lists you wish to enable.
$enableLayers = ["LAYER1","LAYER2","LAYER3"];
$allLayers = $oMapFinal->getAllLayerNames();
foreach ($allLayers as $evalLayer)
{
$layer = $oMapFinal->getLayerByName($evalLayer);
$layer->updateFromString("STATUS MS_OFF");
foreach ($enableLayers as $setLayer)
{
if ($setLayer === $evalLayer)
{
$layer->updateFromString("STATUS MS_ON");
}
}
}
Then call your draw statement.
Let me know if that works, I just templated that code without any testing.