I'm trying to add a CSS class to some certain pages for some certain menu styling depending on the current alias path. It works well with the following function but I'm wondering is there another way to split the current alias parts so I can use them as arguments? Here's my present function:
function mytheme_preprocess_html(&$vars) {
$path = drupal_get_path_alias($_GET['q']);
$aliases = explode('/', $path);
if (isset($aliases[2]) && $aliases[2] === 'foo') {
$vars['classes_array'][] = 'bar';
}
}