Reply to Please help wit{h array search technique?

Your name:

Reply:


Posted by bobmct on 09/29/05 06:49

Gentlemen;

Can someone recommend the best way to search a single dimension array?
I'm currently using a for loop and it doesn't seem to be working
accurately. Here's an example:

$_AV=array(0 => '0100',
1 => '0200',
2 => '0300',
3 => '0400',
4 => '0500'
};

$arg="0225";


for($X=count($_AV);$X>=0;$X--) {
if ($_AV[$X] > $arg) {
$result=$X;
break;
}
}


According to my requirements, the result should be set to 1 which is
the index to the element that is either equal to or less than but
closest to the $arg value.

Is there a better way to accomplish this??

Any/all suggestions appreciated.

Thanks

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация