Reply to Re: Problem creating working array value pair

Your name:

Reply:


Posted by Csaba Gabor on 06/14/06 14:34

Paul Lautman wrote:
> > When I enter
> > 'http://localhost/template.php?page=plan2', I get the default 'home'
> > page.
> >
> > For the life of me I don't see what is wrong.
> > <?php
> > $allpages=array(
....
> > 'The Plan'=>'plan1',
> > 'The Plan'=>'plan2',
> > 'The Plan'=>'plan3'
> > );
>
> Further on the actual problem, it seems that if a key value is repeated,
> then array_search will only return that key if the value found is the last
> one in the list with the same keys. So for your example, it'll work for

Without intending bearing on the OP's problem ... If you want to search
for multiple instances of the same value in an array, you can use
array_intersect to return all the matching instances, complete with
original keys:
$aRes = array_intersect($allpages, array("search term"));
So if you wanted to get the last matching key you could do:
$lastKey = array_pop(array_keys(array_intersect($allpages,
array("search term"))));

Csaba Gabor from Vienna

[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

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