Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8037153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:50:30+00:00 2026-06-05T02:50:30+00:00

I have a PHPArray : $fullData = array ( array ( ‘id’ => 23123,

  • 0

I have a PHPArray :

$fullData = array ( 
        array ( 'id' => 23123, 'name'=>'a', number =>...),
            array()....
);

This full dataset is displayed to the user.
However if he comes from a form page, I POST data to alter this array.

I need to search the array fields, with respect to the user fields.
So if any POST data if not filled, I default the value to all.

if( $resetData == 1) {
    foreach ($params as $i=>$k) {
        if($k!='all') {
            $fields[][$i] = $k;
        }
    }...

Thus getting the user filled data in the fields array.
Now how do I search the data filled be the user, in an SQL AND format.
example : name == ‘aaditi’ AND profile == ‘student’, would list out all data with the names aaditi that have the student profile

I tried various functions like array_search and strstr, and some other questions on stackoverflow, but they are mostly restricted to a single key value search.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:50:32+00:00Added an answer on June 5, 2026 at 2:50 am

    I would search the data array line by line finding all those things that match the passed filters. Taking your field array to be a key=>value where key is the column name and value is the wanted value,

    $outputArray = array();
    foreach($fullData as $row) {
        $addToOutput = true;
        foreach ($fields as $field) {
            foreach($field as $key => $value) {
                if (!isset($row[$key]) || $row[$key] != $value) {
                    $addToOutput = false;
                }
            }
        }
        if ($addToOutput == true) {
            $outputArray[] = $row;
        }
    }
    

    It isn’t the most efficient solution and I am sure that a better one could be found, but this should work ok at least for not rediculously huge sets of data (>100,000 rows with 10 columns apiece). You could also run this same algorithm with no parameters and all the data should come out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP array which looks like this example: $array[0][0] = 'apples'; $array[0][1]
I have a PHP array that looks like this: Array{ [0] { 'id' =>
I have this array in PHP: array( [0] => array( 'username' => 'user1' )
I have a php array called $user. At the minute I am getting the
I have a PHP array like this one: array( [0] => 1 [1] =>
For example I have a PHP array, such as this one <?php $s= array('a','b','c','d','e','f')
i just have a php array with number that i've explode to separate itens,
I have a php array How can I compare all values of this array
I have a PHP array that looks like this: Array ( [0] => Array
I have php array like this: Array ( [0] => Array ([electronics] => TV

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.