I have some PHP in the head tag of my HTML doc (see 3 below), this loads the correct CSS stylesheet dependent on which webpage lander is in the database for that particular domain. The code below is intended for a very large growing group of 100+ domains.
I was wondering if the code I have is most efficient or whether the group can be compacted into an array maybe? This would mean that I would not need so many repeated lines eg.
1. My 1st attempt at (new) shorter code:
@if(strpos(strtolower($domdata->Lander),'bowling','birthday','cars','etc..') !== false)
<link rel="stylesheet" href="/css/custom/custom-group.css">
@endif
2. My 2nd attempt at (new) shorter code, but still too long and probably wrong:
@if(strpos(strtolower($domdata->Lander),'bowling') || (strpos(strtolower($domdata->Lander),'birthday') || (strpos(strtolower($domdata->Lander),'cars') !== false)))
<link rel="stylesheet" href="/css/custom/custom-group.css">
@endif
3. My (existing) long code:
@if(strpos(strtolower($domdata->Lander),'bowling') !== false)
<link rel="stylesheet" href="/css/custom/custom-group.css">
@endif
@if(strpos(strtolower($domdata->Lander),'birthday') !== false)
<link rel="stylesheet" href="/css/custom/custom-group.css">
@endif
@if(strpos(strtolower($domdata->Lander),'cars') !== false)
<link rel="stylesheet" href="/css/custom/custom-group.css">
@endif
Aucun commentaire:
Enregistrer un commentaire