/    Sign up×
Community /Pin to ProfileBookmark

nopt sure how this works

i have this script that reports the server names back to me from a domain name, what i want to do is store one of the items from the array in a variable, but when i do that, all i get is a letter.

if (checkdnsrr($domain, “MX”)) {

getmxrr($domain, $mxhosts);

foreach($mxhosts as $mxKey => $mxValue){
$test = $mxValue;
//print(“$mxValue<br>”);
print(“$test<br>”);
}

}

also how does this exactly work
foreach($mxhosts as $mxKey => $mxValue){

thanks

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 17.2005 — For debugging to help figure out what's going on, I'd insert a print_r() after the getmxrr() call to see what the data (if any) looks like. Also, you should check the return value to see if anything at all was found.
[code=php]
if (checkdnsrr($domain, "MX"))
{
$result = getmxrr($domain, $mxhosts);
if($result) # found something
{
# DEBUG
echo "<pre>";
print_r($mxhosts);
echo "</pre>";
# /DEBUG
# rest of code for processing results...
}
else
{
# might want something here for when getmxrr() fails or returns nothing
}
}
[/code]

[b]foreach($array_name as $key => $value)[/b] walks through each element of array "array_name" and sets the value of $key to the array index for the current array element, and $value is the value contained by that array element.
×

Success!

Help @keko2005 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.26,
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,
)...