Hello to everybody,

I am using the following function in order to search  in multi-dimensional 
array, as per note added on http://it.php.net/array_search,
[code]
function array_search_recursive($data0, $FinRecSet, $a=0, $nodes_temp=array()){
global $nodes_found;
  $a++;
  foreach ($FinRecSet as $key1=>$value1) {
    $nodes_temp[$a] = $key1;
    if (is_array($value1)){
      array_search_recursive($data0, $value1, $a, $nodes_temp);
    }
    else if ($value1 === $data0){
      $nodes_found = $nodes_temp[1];
    }
  }
  return $nodes_found;
}
[/code]

where
$data0 is a date (ex:'1-1-2008')
and $FinRecSet is an array containing financial entries
like this
Array (

=> Array ( [Id] => 281 [Date] => 01-01-2008 [FCode] => A01 [Descr] => Prova 
[Debit] => 100.00 [RunDeb] => 2065300.64 [Credit] => 0.00 [RunCre] => 
3020765.67 [RunBal] => -955465.03 [Rec] => 0 ) [1] => Array ( [Id] => 282 
[Date] => 01-01-2008 [FCode] => A02 [Descr] => Prova [Debit] => 120.00 [RunDeb] 
=> 2065420.64 [Credit] => 0.00 [RunCre] => 3020765.67 [RunBal] => -955345.03 
[Rec] => 0 ) ect....

when I run function I get exactely the last entry with date = '1-1-2008', 
problem is when I don't have entries on such date, for that I should modify 
function in order to get entry on older date available before $data0.
For example if $date0 = '1-1-2008'
and first entry is available only on '30-12-2007', how should I modify function?

Thank you for your attention.

Amos



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to