cakephp set class with checkboxes
I have an array that looks like:
Array (
[63] => 0
[64] => 1
[65] => 1
[66] => 0 )
Is there a way to extract the keys for all the values that are equal to 1 (in this case I just want 64 and 65) using Set::extract or Set::remove or some 开发者_高级运维other method?
One way may be like this:
$new_array = array();
foreach($your_array as $value)
{
if ($value == 1)
{
$new_array[] = $value;
}
}
print_r($new_array);
Or you can use the array_filter function.
Sarfrarz is right.. array_filter will be the most efficient solution.
but if you still want to use cakphp's builtin method then you should look at the manual for such things.
http://book.cakephp.org/view/640/Set
精彩评论