array question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

array question

Post by John Cartwright »

i have this array which fills the drop down menu

Code: Select all

<?php
					echo "	<select name='cal-level'>";
            			
						$levels = array("i","p","m","im","o", $_SESSION["admin"]["cal-level"]);
						$levels = array_unique($levels);	

						foreach ($levels as $level)
						{
							echo "<option>".$level."</option>";
						}
						
            	  echo "</select>
?>
And the session will have one of those depending on the database... the problem is i always want the session var to appear first in the drop down menu and have no idea how to do this
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

1. make the session variable the first element in the array
2. print out the first element in the array (the session var)
3. use a loop that prints out every element in the array that is after the first element

??
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

wow i feel so stupid...

thanks enigma

edit

NIGMA!!!!!!!
Last edited by John Cartwright on Tue Jul 20, 2004 11:25 pm, edited 1 time in total.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

haha, nigma~!

but hey, at least we figured things out, who cares if you feel stupid :)
Post Reply