Reply to Re: Problem creating working array value pair

Your name:

Reply:


Posted by Rik on 06/14/06 14:18

alanbe wrote:
> Problem is that the first 9 work, that is I get the correct page
> linked.

> if (isset($_GET['page']) AND (array_search($_GET['page'],
> $allpages))) { $thispage=$_GET['page'];
> $title=array_search($thispage, $allpages);
> }

try:
if (isset($_GET['page']) && in_array($_GET['page'],$allpages)){
//code
}

array_search returns a key, not a boolean. Might work in a lot of cases, but
highly quircky here.
Like it states in the maual:

Warning:
This function may return Boolean FALSE, but may also return a non-Boolean
value which evaluates to FALSE, such as 0 or "". Please read the section on
Booleans for more information. Use the === operator for testing the return
value of this function.

I would have reversed the array though:
'plan1' => 'The Plan' etc..

if(isset($_GET['page']) && array_key_exists($_GET['page'],$allpages)){
$thispage = $_GET['page'];
$title = $allpages[$_GET['page']];
}

Grtz,
--
Rik Wasmus

[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

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