Set active class in a Php foeach

Have no idea what is $link->slug is it a post type property? or taxonomy? Something else? in case of something else you can use a strpos in comparing url?

echo'<a href="https://wordpress.stackexchange.com/questions/73941/. network_site_url() ."/services/' .$mylink->slug . ' class=". ($mylink->slug) 
    . (stripos($_SERVER["REQUEST_URI'], $mylink->slug) !== false ? ' active ':'').'" >';

in case of post use get_post_field

global $wp_query; // little trick...
echo'<a href="https://wordpress.stackexchange.com/questions/73941/. network_site_url() ."/services/' .$mylink->slug . ' class=". ($mylink->slug) 
    .($mylink->slug === get_post_field("slug', get_the_ID(), false) ? ' active ':'').'" >';

in case of this is a taxonomy archive page using a query object (actualy you can use it in axample above too)…

global $wp_query; // little trick...
echo'<a href="https://wordpress.stackexchange.com/questions/73941/. network_site_url() ."/services/' .$mylink->slug 
    . ' class=". ($mylink->slug) .($mylink->slug === $wp_query->queried_object->slug ? " active ':'').'" >';