How to add a CSS class to some certain pages depending on the path alias?
You should be using Drupal's arg function:
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/arg/7

Something like this should work:

function mytheme_preprocess_html(&amp;$vars) {

    if (arg(2, drupal_get_path_alias()) == 'foo') {
        $vars['classes_array'][] = drupal_clean_css_identifier(arg(2, drupal_get_path_alias()));
    }
}


Added drupal_get_path_alias() as an arguement of arg() as suggested by @koivo