php从数组中获取特定的查询信息

 <?php

echo "Connecting Database <br>";
$server = 'UKVDEMO03'; //Here you're server
$database = 'smtpFetch';//here the database you want to connect to
$user = 'shoaibsg';//here te user WHO HAS THE RIGHT PERMISSIONS AT THE DATABASE
$pass = '1111111';//and here the user's password
$dsn = "Driver={SQL Server};Server=$server;Database=$database;";
$connect = odbc_connect($dsn, $user, $pass); 
echo "Successfully connected....";

//getting subscribe user detail
$subQuery="select emailAddress, dataSet from userDetail";
$subRes=odbc_exec($connect, $subQuery);
$ix=odbc_num_rows($subRes);
//$newArray[]=$newArray array;
$row[]=array();
$newArrayD[]=$row;
$i=0;
$xc=0;
if($ix>0)
{

    while($row=odbc_fetch_array($subRes))
    {
            $newArrayD[$row['emailAddress']] =$row['emailAddress'];
            $newArrayD[$row['dataSet']] =$row['dataSet'];
    }

}
foreach($newArrayD as $arrayD)
{ $i++; 
echo "<br> -" . $arrayD;
echo "-i increment -" . $i;
}


?>

The above displays the below output

-Array -shoaib@xyz.com -SSCRUS_CS2002 -nick@xyz.com -SSCE_CS2002

Now the problem: if I need to display only the emailAddress only in foreach loop it only displays the first character (I used below in foreach loop)

echo "<br> -" . $arrayD['emailAddress'];

such as above output displays as - -s -S -n -S

I am baffled, please please help

Your code to generate the array is off. Try this:

while ($row=odbc_fetch_array($subRes))
{
    $newArrayD[$row['dataSet']] = $row['emailAddress'];
    // This would generate for example $newArrayD['SSCRUS_CS2002'] = 'shoaib@xyz.com'
}

Then, to display them, iterate through the array:

foreach ($newArrayD as $dataset=>$emailaddress)
{
    echo "- $emailaddress<br />";
}

EDIT - To save both in seperate arrays:

$newArrayD = array('dataset' => array(), 'emails' => array());

while ($row=odbc_fetch_array($subRes))
{
    $newArrayD['dataset'][] = $row['dataSet'];
    $newArrayD['emails'][] = $row['emailAddress'];
}

To iterate through the emails:

foreach ($newArrayD['emails'] as $emailaddress)
{
    // Code you wish to execute
}

To iterate through the datasets:

foreach ($newArrayD['dataset'] as $dataset)
{
    // Code you wish to execute
}

Using this method, the $newArrayD['dataset'][0] will be the dataset linked to $newArrayD['emails'][0] etc.