0

Im trying to make an search function in codeigniter. I have an array with the value of multiple diffrent checkboxes. (groups, times, special etc)

Im first using the keys form te array to make the search array like so

 $data = array_keys($data);
    $find =  array();
 foreach($data as $selection){
     if(!strpos($selection,'groep') == 0){

        $find[$selection] = 1 ;
     }

     $find[$selection] = 1 ;

 }

the result of the array is like this:

Array ( ["fri_morning"] => 1 ["groep_1"] => 1 )

what isnt working is the next bit of code where im trying to use the second array to make multiple where selections for my query

im doing it like this:

 $where = '';

    foreach($find as $finds){
        echo array_keys($finds);die();
        $name = key($finds);
       $where .=  '$this->db->where'.name.','.$finds[$name].')';
    };

Im getting the following error

Message: array_keys() expects parameter 1 to be array, integer given

What am i doing wrong/missing here

1 Answer 1

3
foreach($find as $finds => $value){
                    ^         ^
                   Key      Value
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.