First of all, I'm not sure if the title is correct but here is what I want to do. I want to use array selected from DB and use it inside for loop. When I dump the array (//print_r($ns1);) it is available. However print_r($host); dump have no data when I print_r it. I think the problem is in $host[] = "@$ns1 $subdomain"; but I'm not so sure. Why I can't print_r($host);? Please help and thanks in advance.
$sql = "SELECT subdomain, ns1, ns2, id_user, counter FROM ns WHERE counter = 1";
$result = mysqli_query($con,$sql);
$subdomain = array();
$ns1 = array();
$ns2 = array();
$id_user = array();
$counter = array();
// Associative array
while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){;
$subdomain []= $row['subdomain'];
$ns1 []= $row['ns1'];
$ns2 []= $row['ns2'];
$id_User[]= $row['id_user'];
$counter []= $row['counter'];
}
$total= count($subdomain);
$host = array();
$ip = array();
$mx = array();
for ($x = 1; $x <= $total; $x++) {
//print_r($subdomain); // both data is available
//print_r($ns1);
$host[] = "@$ns1 $subdomain";
print_r($host);
$ip = `/usr/bin/dig $host +short A`;
$mx = `/usr/bin/dig $host +short MX`;
print_r($host);
}