Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Help printing in PHP array!!! Please! (https://www.warriorforum.com/programming/502665-help-printing-php-array-please.html)

Ricky Dawn 12th December 2011 06:58 AM

Help printing in PHP array!!! Please!
 
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();

?>


KirkMcD 12th December 2011 09:34 AM

Re: Help printing in PHP array!!! Please!
 
You need to add the seperator when you are building the links.


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