Jump to content

why mysql_fetch_array into multidimensional array?


levivel

Recommended Posts

I'm trying to pull out a list of id's into a simple array, but I seem to be getting is a multidimensional array. All I need is a simple array with the list of id's. What am I doing wrong?

//Get list of all sentence id's selected for test in database
$allSentenceQuery = mysql_query("SELECT id FROM associations WHERE validate='checked'") or die("First Query: ".mysql_error());
while ($allSentenceResult = mysql_fetch_array($allSentenceQuery)){
$allSentences[] = $allSentenceResult['id'];
//echo "allSentences: ".$allSentenceResult['id'];
}

And what I get:

"Array ( [0] => Array ( [1] => 2 [2] => 3 etc...."

 

Thanks for your help!

What is that output the result of?

 

sorry, I didn't mention the other important part of the story:

 

I ran that array through array_diff to compare it with another array, and the output is actually the result of the arraydiff function. What I wanted to do was remove the elements from the first array that also appeared in the second array.

 

$rateSentences[] = array_diff($allSentences,$subjectSentences);

 

$subjectSentences is pulled the same way as allSentences in my first post. The output in my first post is a print_r of $rateSentences.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.