What I am tring to do is ; depending on the conditions (in this case if the domain is a .com domain ) then choose the first variation. If not, choose the second variation. <? $dom = $_GET['dom']; function spin($var){ $words = explode("{",$var); foreach ($words as $word) { $words = explode("}",$word); foreach ($words as $word) { $words = explode("|",$word); if ($dom = "com"){$word = $words[0];} else {$word = $words[1];} echo $word." "; } } } $text = "<font size=\"6\">is this the domain {<b>.com</b> |<b>.us</b> } ?, so you are from {anywhere|usa} ?</font><br />"; spin($text); ?> PHP:
$dom = parse_url($_GET['dom'], PHP_URL_HOST); Code (markup): And for the if matching 1 thing you could use is this. if (preg_match('/\.com$/i', $dom)) { $word = $words[0]; } PHP: What all this should do is. 1. parse the get value from $_GET['dom'], which just returns domain, e.g - google.com , google.co.uk, subdomain.google.com etc etc 2. in the preg match we search for .com and indicate that the search string end after the pattern ($), so it dont match subdomain.commercial.net and the likes Search using case-insentive (i), so it also macthes if one write .COM For variations replace .com with .co.uk , .net etc When you have more variations in iam sure it could be written using less code ( so not using if -> elseif -> elseif -> else )
thanks all but, my problem (way) is to spin the text, not get the domain name. I was trying to spin the text based on what the domain was. all sorted anyways.. thanks again.