I have the following array:
$my_array = array (
'city' => $this->input->post('city'),
'country' => $this->input->post('country'),
'state' => $this->input->post('state'),
'miles' => $this->input->post('miles')
);
Which short php function or method can I use to check if all array items are set? Right now I’m using the following code
$my_array = array_filter($my_array);
if (!empty($my_array['city']) && !empty($my_array[['miles']) && !empty($my_array[['state']) && !empty($my_array['country']))
{
//do something
}
note: I’m using the array_filter() function to remove all entries from a query that equal FALSE.
It seems like you can just
countthe number of elements left after filtering: