Using filters with CGridView and CArrayDataProvider

Comparing #4 with #8

Content

[...]
*/
public function filter(array $data)
{
foreach ($data AS $rowIndex => $row) {
foreach ($this->filters AS $key => $searchValue) {
if (!
emptyis_null($searchValue) AND $searchValue !== '') {
$compareValue = null;
[...]
```

(By @KonApaz)
 
If you want to apply full comparisons (>, <, >=, <=, =) use this
 
 
 
```php 
if (substr($searchValue, 0, 2) == '<=') {
 
    if ($compareValue > substr($searchValue, 2)) {
 
        unset($data[$rowIndex]);
 
    }
 
} else if (substr($searchValue, 0, 2) == '>=') {
 
    if ($compareValue < substr($searchValue, 2)) {
 
        unset($data[$rowIndex]);
 
    }
 
} else if ($searchValue[0] == '<') {
 
    if ($compareValue >= substr($searchValue, 1)) {
 
        unset($data[$rowIndex]);
 
    }
 
} else if ($searchValue[0] == '>') {
 
    if ($compareValue <= substr($searchValue, 1)) {
 
        unset($data[$rowIndex]);
 
    }
 
} else if (stripos($compareValue, $searchValue) === false) {
 
    unset($data[$rowIndex]);
 
}
 
```
 
 
 
Controller
----------
[...]
'filter'=>$filtersForm,
));
```