print or echo question


#1

Hi

I have a php script that does a host command and returns what I want, BUT I can’t get it to print the way I want??? Please help.

foreach ($host_list as $value){
echo “You entered $value, the result is:
”;
$host = host -W 1 $value;
echo $host . “
”;
}

Now lets say I did my query on yahoo.com my current code displays it like:
You entered yahoo.com, the result is:
yahoo.com has address 216.109.127.29 yahoo.com has address 216.109.127.30 yahoo.com has address 66.218.71.112 yahoo.com has address 66.218.71.113 yahoo.com has address 66.218.71.114 yahoo.com has address 216.109.127.2

My goal is:
You entered yahoo.com, the result is:
yahoo.com has address 216.109.127.29
yahoo.com has address 216.109.127.30
yahoo.com has address 66.218.71.112
yahoo.com has address 66.218.71.113
yahoo.com has address 66.218.71.114
yahoo.com has address 216.109.127.2

Please advise… Thanks

Rob


#2

From first glance. I think that this is the wrong part of the code to make the adjustments at. Either that or I don’t understand the code.


#3

Can anyone HELP???


#4

I would also say its the wrong code, but you could try changin it so the variable has the
tag.

eg.
$host = “host -W 1 $value” . “
”;
echo “$host”;
}


#5

Thanks Pablo… but adding the
did not help.

Why would you say its the “wrong code”?

Any input is apperciated…


#6

this achieved what I needed:

foreach ($host_list as $value) {
echo “You entered $value, the result is:
”;
$host = host -W 1 $value;
//print “$host” . “
”;
echo “

$host
”;
}

#7

Well Sorry we couldn’t help, but glad that you found a solution.