Jump to content

PHP Link Array


ShoeLace1291

Recommended Posts

I have an array that I am trying to use to display links more easily so I can add a bullet in between them, but I can't figure out the syntax.  This is my code:

 

	if($result['accnt_found']){

		$link = array(
			  		  'link1href' => "index.php",
					  'link1name' => '', $board['name'], ' Home',
					  'link2href' => "logout.php",
					  'link2name' => "Logout",
					  'link3href' => "profile.php",
					  'link3name' => "My Profile",
					  'link4href' => "members.php",
					  'link4name' => "Members",
					  'link5href' => "events.php",
					  'link5name' => "index.php?act=events",
					  'link6href' => "index.php?act=help",
					  'link6name' => "Help"
					  );
					  
			$button = array(
					  		'link1' => '<a href="'$link['link1href']'" name="'$link['link1name']'">Index</a>',
							'link2' => '<a href="'$link['link2href']'" name="'$link['link2name']'">Logout</a>',
							'link3' => '<a href="'$link['link3href']'" name="'$link['link3name']'">Profile</a>',
							'link4' => '<a href="'$link['link4href']'" name="'$link['link4name']'">Members</a>',
							'link5' => '<a href="'$link['link5href']'" name="'$link['link5name']'">Events</a>',
							'link6' => '<a href="'$link['link6href']'" name="'$link['link6name']'">Help</a>'
							);

	echo '
		  ', implode('  &#8226  ', $buttons) ,' ';
		  
		 }

Link to comment
https://forums.phpfreaks.com/topic/93413-php-link-array/
Share on other sites

$array = array("<a href='index.php'>Home</a>", "<a href='login.php'>Login</a>", "<a href='register.php'>Register</a>", "<a href='index.php?act=faq'>Help</a>");
	  		
				foreach($array as $buttons => $links){

					echo "<a href='$links'>$buttons</a> ";

				}

 

That's my current code.  Displays as this:

 

Home'>0 Login'>1 Register'>2 Help'>3

 

Home, Login, Register, and Help are links like they should be, but '>0, '>1, etc shouldn't be there... Any thoughts?

Link to comment
https://forums.phpfreaks.com/topic/93413-php-link-array/#findComment-479559
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.