Reply to Re: Brain freeze - Help re Multidim Arrays.

Your name:

Reply:


Posted by J.O. Aho on 10/11/58 11:52

Mr Smith wrote:
> I have a multidim array (only 2 columns) that I need to search in the
> first column for a particular value (there are no duplicate values,
> all are unique).
>
> When it finds it, I need it to return the value held in the 2nd
> column.

function return2ndcol($array,$value) {
for($i=0;$i<count($array);$i++) {
if($value=$array[$i][0]) {
return $array[$i][1];
}
}
return false;
}


$second_column=return2ndcol($the_multi_dim_array,$first_column_value);

false is returned if there is no such value that you wanted to search for,
this will work fine as long as you don't return the value 0, as in an
if-statement 0 == false.


//Aho

[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

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