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! Link to comment https://forums.phpfreaks.com/topic/224775-why-mysql_fetch_array-into-multidimensional-array/ Share on other sites More sharing options...
Pikachu2000 Posted January 18, 2011 Share Posted January 18, 2011 What is that output the result of? Link to comment https://forums.phpfreaks.com/topic/224775-why-mysql_fetch_array-into-multidimensional-array/#findComment-1161082 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. Link to comment https://forums.phpfreaks.com/topic/224775-why-mysql_fetch_array-into-multidimensional-array/#findComment-1161087 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. Link to comment https://forums.phpfreaks.com/topic/224775-why-mysql_fetch_array-into-multidimensional-array/#findComment-1161089 Share on other sites More sharing options...
levivel Posted January 18, 2011 Author Share Posted January 18, 2011 damn, thanks a lot! Link to comment https://forums.phpfreaks.com/topic/224775-why-mysql_fetch_array-into-multidimensional-array/#findComment-1161105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.