/    Sign up×
Community /Pin to ProfileBookmark

Extract host portion from an array..

This is doing my head in:

$domains_listA = array(‘http://[B]mysite[/B].localhost’, ‘http://www.[B]siteone[/B].co.uk’, ‘http://[B]siteone[/B].co.uk’, ‘http://www.[B]sitetwo[/B].co.uk’, ‘http://forums.[B]sitetwo[/B].co.uk’, ‘http://www.[B]3sitethree[/B].co.uk’, ‘, ‘http://www.[B]sitefour[/B].net’,);

I want to extract things like:

mysite, siteone, sitetwo, 3sitethree, sitefour

Anyone help ?

Basically I want my script to do different things depending on which host Im running on.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmMar 12.2015 — Can you clearly define what you want? I see how you have highlighted your preference, but unless you can come up with why you chose parts, how do you expect any logic to do it?

Also - did you create this array by hand? Do you expect this array to always be created that way? If so, drop the excess parts such as http: or // or www. to make the selection/finding process easier, should you figure one out. Or simply put in the individual words that you want to use all by themselves as in:

('mysite','siteone','sitetwo','3sitethree','sitefour')

and then simply use a foreach to cycle through them.
Copy linkTweet thisAlerts:
@axemanauthorMar 12.2015 — Thanks. Got it now.
×

Success!

Help @axeman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...