levivel Posted January 17, 2011 Share Posted January 17, 2011 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! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 18, 2011 Share Posted January 18, 2011 What is that output the result of? Quote Link to comment Share on other sites More sharing options...
levivel Posted January 18, 2011 Author Share Posted January 18, 2011 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. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 18, 2011 Share Posted January 18, 2011 array_diff returns an array, so by assigning the result of array_diff() to the $rateSentences[] array, you're creating a multidimensional array. Quote Link to comment Share on other sites More sharing options...
levivel Posted January 18, 2011 Author Share Posted January 18, 2011 damn, thanks a lot! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.