Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7574291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:24:03+00:00 2026-05-30T16:24:03+00:00

I am trying to create custom function for Main Nav menu where I can

  • 0

I am trying to create custom function for Main Nav menu where I can only write menu item name and it will automatically wrap with

  • my content
  • Also I want variable where I can define url for each menu item.

    below is my code and giving me Parse error: syntax error, unexpected T_VARIABLE

    function the_main_nav($navlinks){
            echo '<nav>';
            echo '<ul>';
    
            $menuitem = $navlinks;
            $pieces = explode("," $menuitem);
            echo $pieces[0];
            echo $pieces[1];
    
            echo $menuitem;         
            echo '</ul>';
            return $pieces;
        }
    

    ——————[Modified code]———————-

    function the_main_nav($navlinks){
    echo '<nav>';
    echo '<ul>';
    
    $menuitem = $navlinks;
    $pieces = explode(" ",$menuitem);
    echo '<li>';
        echo $pieces[0];
        echo '</li>';
    echo '<li>';
        echo $pieces[1];
        echo '</li>';
    
    echo '</ul>';
        echo '</nav>';      
    }
    

    Now I want to make it dynamic like instead of getting value from [0] [1]..so on i want it will automatic generate as per the input character and create list with li

    • 1 1 Answer
    • 0 Views
    • 0 Followers
    • 0
    Share
    • Facebook
    • Report

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    1 Answer

    • Voted
    • Oldest
    • Recent
    • Random
    1. Editorial Team
      Editorial Team
      2026-05-30T16:24:04+00:00Added an answer on May 30, 2026 at 4:24 pm

      You are missing the ,. You have to separate the argument of explode using comma.

      $pieces = explode(",", $menuitem);
      
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I'm trying to create a custom patch for Quartz Composer that will function just
    I'm trying to create an export Excel/CSV function that will iterate through a custom
    I'm trying to create a custom function that I can place in a queryset
    I'm trying to create a custom control - a button - which will have
    I am trying to create a custom jQuery selector that will put focus() on
    I'm trying to create a custom function for a SQLite database I'm using with
    I'm trying to create a custom function that unbinds and then binds an event.
    I'm trying to create a custom function to take a array and add comma.
    I'm trying to programmatically create the custom horizontal menu for my custom module, but
    I am trying to create a custom jquery function which has two parameters, the

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • SEARCH

    Footer

    © 2021 The Archive Base. All Rights Reserved
    With Love by The Archive Base

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.