0

Can any body please tell me how to filter this array. I want to show only those records in which hide_chat_1 or hide_chat_2 are 0.I does not want hide_chat_1 or hide_chat_2 of value 1

Array(
    [0] => Array(
        [unread_msg] => 0[user_id] => 524[c_id] => 152[first_name] => Sanjay . palial@gmail . com[last_name] => Palial[user_name] => sanjay . palial@gmail . com[loginstatus] => 1[user_one] => 524[user_two] => 19[user_img] => [property_id] => 1571[locality] => Sector125[city] => Mohali[online_status] => 0[hide_chat_1] => 0[hide_chat_2] => 0
    ) [1] => Array(
        [unread_msg] => 0[user_id] => 465[c_id] => 151[first_name] => Alvinseo[last_name] => Verma[user_name] => alvinseo[loginstatus] => 1[user_one] => 465[user_two] => 19[user_img] => 296_IMG20150607083310 . jpg[property_id] => 1571[locality] => Sector125[city] => Mohali[online_status] => 0[hide_chat_1] => 0[hide_chat_2] => 1
    ) [2] => Array(
        [unread_msg] => 0[user_id] => 519[c_id] => 138[first_name] => ATSGolf[last_name] => Meadows[user_name] => atsgolfmeadows[loginstatus] => 1[user_one] => 19[user_two] => 519[user_img] => 705_2F79BB9221B2F96F7305AA96D01DD9EBD96BE4B0D7506F9954pimgpshfullsizedistr . png[property_id] => 1526[locality] => BarwalaRoad,
        Derabassi[city] => Derabassi[online_status] => 0[hide_chat_1] => 0[hide_chat_2] => 0
    ) [3] => Array(
        [unread_msg] => 0[user_id] => 504[c_id] => 134[first_name] => Mandeep[last_name] => Talwar[user_name] => mandy[loginstatus] => 0[user_one] => 19[user_two] => 504[user_img] => [property_id] => 1485[locality] => Sector114[city] => Mohali[online_status] => 0[hide_chat_1] => 1[hide_chat_2] => 0
    )
)

It may be looks silly or easy questions for some of you. But any help is appreciable.

0

1 Answer 1

1

Try This

$results is your Array

$new_result =  array();
    foreach ($results as $value) {
        if($value['hide_chat_1'] == '0' || $value['hide_chat_2'] == '0'){
                $new_result[] = $value; 
        }

}
print_r($new_result);
Sign up to request clarification or add additional context in comments.

4 Comments

what if hide_chat_1 = 0 and hide_chat_2 = 1 then it will show me all records I want the filter if any of this have value have 1.. In this case its give me result if I add only one condition in if
yess u r right if any of them is one then it should be hide records
just change in if condition || to &&.
yes my silly mistake forgot about && now its working :) thanks alot

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.