mkelley Posted February 2, 2007 Share Posted February 2, 2007 I have the code below and it produces <title>M.Kelley</title> <link rel='stylesheet' href='mkelley.com.css' type='text/css' /> <?php $new_domain = $_SERVER['HTTP_HOST']; switch ($new_domain){ case "mkelley.com": echo "<title>M.Kelley</title>"; echo "<link rel='stylesheet' href='$new_domain.css' type='text/css' />"; break; case "www.mkelley.com": echo "<title>M.Kelley</title>"; echo "<link rel='stylesheet' href='$new_domain.css' type='text/css' />"; break; } ?> I'm very very new to regex, how can I remove the . from domain.com or from www.domain.com ? I'd like it to produce <title>M.Kelley</title> <link rel='stylesheet' href='mkelleycom.css' type='text/css' /> Link to comment https://forums.phpfreaks.com/topic/36724-remove-dots-from-dot-coms/ Share on other sites More sharing options...
c4onastick Posted February 2, 2007 Share Posted February 2, 2007 This is one way: $text = preg_replace('/\.(?!css)/', '', $text); Assuming you're just dealing with the form 'foo.com.css' Link to comment https://forums.phpfreaks.com/topic/36724-remove-dots-from-dot-coms/#findComment-175222 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.