Reputation: 2332
Please advise on how to do this.
I have a html page with two different links like below
1) http://domainONE.com/?a=100&b=$bvalue (this url is around in 45 places)
2) http://domainTWO.com/?a=200&b=$bvalue (this url is around in 30 places)
Now I would like dynamically change (prefer PHP based solution) to assign b= value(like link1, link2 link3…link45) for domainONE.com and then b= number (like link46, link47 link48…link75). Looking to assign the b=$bvalue using a loop or other ways based on domain name so I don’t have to hardcode by finding each url on the page with link1 till link75)
I can explain more if it’s not clear. I am trying not to use jquery based solution thinking if that takes time to manipulate.
Regards
Upvotes: 0
Views: 58
Reputation: 78994
Something like this with a switch:
switch($_SERVER['SERVER_NAME']) {
case 'www.domain1.com':
$bvalue = 100;
break;
case 'www.domain2.com':
$bvalue = 200;
break;
}
Or something with an array:
$domains = array('www.domain1.com' => array('bvalue' => 100),
'www.domain2.com' => array('bvalue' => 200),
);
$current = $_SERVER['SERVER_NAME'];
$bvalue = $domains[$current]['bvalue'];
Depending on your requirements you might look through $_SERVER
specifically $_SERVER['HTTP_HOST']
for something else or you may need to manipulate it somewhat to get the string that you want.
Upvotes: 2