2 Small Array Questions (retrieving results)
Posted: Sun Apr 30, 2006 3:21 pm
Not had luck finding information on how to do this, so maybe someone can shed some light.
How would I write something to work like follows (where products.php, news.php and contact.php could be selected from the array):
Is it also possible to return the array number for an array item? for example:
Thanks for any help.
Code: Select all
$getcurrentpage = $_SERVER['PHP_SELF'];
$i = 0;
$news = array(
"Home" => "home.php",
"Products" => "products.php",
"News" => "news.php",
"Contact" => "contact.php"
);How would I write something to work like follows (where products.php, news.php and contact.php could be selected from the array):
Code: Select all
if ($getcurrentpage equal to ($news[1] to $news[3])){
echo "Non-Home Page\n";
}Code: Select all
while($news = each($news)){
if ($news["value"] == $getcurrentpage){
$page = $news[$i]; //get number of array item
}
$i++;
}
echo $page;