php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13169 Problem with array_diff()
Submitted: 2001-09-06 04:19 UTC Modified: 2001-09-13 14:18 UTC
From: spam at tefen dot net Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.0.6 OS: Debian
Private report: No CVE-ID: None
 [2001-09-06 04:19 UTC] spam at tefen dot net
My site is a series of questions that users answer.  In order to track which questions are answered and which are not I've developed two mysql tables:

inever_statements which contains all the questions and their "statement_id"
inever_answers which contains all the answers for each question from each user

Because mysql doesn't have a method for doing isin queries I've instead loaded two arrays.  One array contains the ids for all the possible questions, the second array contains all the ids for the questions the current user has answered.  By running array_diff() on these two arrays I should be able to create a list of ids for questions the current user hasn't answered.

This worked perfectly for quite a while.  However, the number of questions is now near 600....  I can load both arays and use print_r() to verify the contents of each.  However, running array_diff() fails if the user has answered a single question.

Is this due to the large number of questions?  Is there perhaps a better way to accomplish the same thing?

One thought I had was to break down the process into a number of smaller comparisions, say limiting the query to 50 or 100 records.  Any other suggestions would be appreciated.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-13 14:18 UTC] venaas@php.net
The problem is that array_diff() doesn't work with array
of arrays any more. File it as a feature request if you
really want it.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 04:01:28 2024 UTC