Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 12th Dec 2011, 06:58 AM   #1
HyperActive Warrior
War Room Member
 
Ricky Dawn's Avatar
 
Join Date: 2010
Posts: 277
Thanks: 7
Thanked 20 Times in 16 Posts
Default
Help printing in PHP array!!! Please!
Share on: 
fb share twitter share gplus share more share

Hey Guys,

I have a small problem I want to create a mini Nav, that looks like:

Test | Test | Test | Test | Last

The only problem Is when I add the | into the array using 'Print' it just appears at the end of the line instead of where eI place it.

Here is the code:

HTML Code:
<?
session_name("BACKPACKING_SESS");

// a finir : emepcher un meme utilisateur de voter plusieurs fois sur un meme hotel en stockant une var de session permaneent ds un cookie
//ini_set("session.use_cookies", 1);	// force session by cookies
//ini_set("session.use_trans_sid", 0);  // forbid session id through url 
//session_set_cookie_params(time()+600);
//stop many votes on same hostels by storing session ids linked to the hostel

session_start();
header("Cache-control: private");

// Create Main Menu Items
function set_mainmenu($group) {

	$mainlink_array = array();
	
	$mainlink_array['Home'] = '/index.html';
	$mainlink_array['General Travel Advice'] = '/general-travel-advice.html';
	$mainlink_array['Backpacking'] = '/backpacking.html';
	$mainlink_array['Gap Year'] = '/gap-year.html';
	$mainlink_array['Transport'] = '/transport.html';
	$mainlink_array['Links'] = '/links.html';

	////////////////////////////////////		
	$mainlink_array['Hostels'] = '/main_hostels.html';
	$mainlink_array['Cheap Flights'] = '/cheap-flights.html';
	////////////////////////////////////



	if($mainlink_array) {

		foreach ($mainlink_array AS $title=>$url) {

			switch ($title) {	 // Set green left corners for the required tabs
				case 'Gap Year':
				case 'Transport':
				case 'Links':
				case 'Cheap Flights':
				case 'Hostels':
					$tab_style = 'green';
					break;
				default: 
					$tab_style = '';
					break;
				
			}

			$mainlinks .= '<li'.($group == $title?' class="selected'.$tab_style.'"':'').(($tab_style)? ' class="'.$tab_style.'"' : '').'><a href="'.$url.'"><span>'.$title.'</span></a></li>';
		}

	}

	if(!$mainlinks) { $mainlinks = '<li></li>'; }

	return $mainlinks;
}

// Create Sub Menu
function set_submenu($group) {

	$sublink_array = array();

	switch ($group) {
		
		case 'General Travel Advice':
			$sublink_array['Passport/Visas'] = '/passports-visas.html';
			$sublink_array['Responsible Travel'] = '/responsible-travel.html';
			$sublink_array['Travel Insurance'] = '/travel-insurance.html';
			$sublink_array['Important'] = '/important-information.html';
			$sublink_array['Mobile Phone'] = '/mobile-phone-user.html';
			$sublink_array['Drugs'] = '/drugs.html';
			$sublink_array['Terrorism'] = '/terrorism.html';
			$sublink_array['Malaria'] = '/malaria.html';
			$sublink_array['Reviews'] = '/reviews.html';
		break;

		case 'Gap Year':
			$sublink_array['Planning Ahead'] = '/planning-ahead.html';
			$sublink_array['Things to consider'] = '/things-to-consider.html';
		break;

		case 'Transport':
			$sublink_array['Europe by Bus'] = '/bus-europe.html';
			$sublink_array['Europe by Car'] = '/car-europe.html';
			$sublink_array['Europe by Train'] = '/train-europe.html';
			$sublink_array['USA by Bus'] = '/bus-usa.html';
			$sublink_array['USA by Train'] = '/train-usa.html';

		break;
		
		case 'Cheap Flights':
			
		break;
		
		case 'Backpacking':
		
			$sublink_array['Backpacking Events'] = '/bus-europe.html';
			$sublink_array['Group Activities'] = '/car-europe.html';
			
			
		break;

		default:

		break;
	}

	if($sublink_array) {
		foreach ($sublink_array AS $title=>$url) {
			$sublinks .= '<li'.($_SERVER['PHP_SELF'] == $url?' class="selected"':'').'><a href="'.$url.'">'.$title.'</a></li>';
				
		}
	}
	
	if(!$sublinks)  { $sublinks = '<li></li>';  }

	return $sublinks;

}


ob_start();

?>
Ricky Dawn is offline  
Unread 12th Dec 2011, 09:34 AM   #2
VIP Warrior
War Room Member
 
Join Date: 2006
Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
Default
Re: Help printing in PHP array!!! Please!
Share on: 
fb share twitter share gplus share more share

You need to add the seperator when you are building the links.
KirkMcD is offline  
Closed Thread


Bookmarks

Tags
array, php, printing


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 05:58 AM.