I am trying to filter more on start_date and end date .
<?php
/*
* filtering an array
*/
function filter_by_value ($array, $index, $value){
if(is_array($array) && count($array)>0)
{
foreach(array_keys($array) as $key){
$temp[$key] = $array[$key][$index];
if ($temp[$key] == $value){
$newarray[$key] = $array[$key];
}
}
}
return $newarray;
}
?>
Example:
<?php
$results = array (
0 =>
array (
'a' => 'U/H',
'b' => 'Modification',
'date' => '02/11/11',
'h' => '17:15:13',
'fullname' => 'First1 Name1',
'desc' => 'Descript ',
),
1 =>
array (
'a' => 'J/M',
'b' => '',
'date' => '03/11/11',
'h' => '17:18:27',
'fullname' => 'First1 Name1',
'desc' => 'Descript more '
),
);
$nResults = filter_by_value($results, 'fullname', 'First1 Name1');
echo '<pre>';
print_r($nResults);
echo '</pre>';
Array
(
[0] => Array
(
[a] => U/H
[b] => Modification
[date] => 02/11/11
[h] => 17:15:13
[fullname] => First1 Name1
[desc] => Descript
)
[1] => Array
(
[a] => J/M
[b] =>
[date] => 03/11/11
[h] => 17:18:27
[fullname] => First1 Name1
[desc] => Descript more
)
)
For Now I want to filter that the function can filter by start_date and end_date
so I change the
function filter_by_value ($array, $index, $value,$start_date,$end_date)
Anyone could How can I filter in the period of date?