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 7055249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:43:33+00:00 2026-05-28T03:43:33+00:00

I have a HTML form where I will be sending all the information to

  • 0

I have a HTML form where I will be sending all the information to the server side. One of my field is like

<option value="bus_info[{$k->bus_id},{$k->route_from},{$k->route_to}]">{$k->route_from} To {$k->route_to},{$k->bus_time}</option>

And when check in PHP side

$bus_information[] = $_REQUEST['bid'];

var_dump($bus_information);`

it shows the following result :

array
  0 => string 'bus_info[1,Guwahati,Amguri]' (length=27)

Now how can I retrieve the elements from the array ? I tried echo $bus_information[0][0]; but it shows the result b ! Why so

  • 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-28T03:43:33+00:00Added an answer on May 28, 2026 at 3:43 am

    Multidimensional arrays don’t work that way in HTML and PHP. You should use this in your form:

    <option value="bus_info[{$k->bus_id}][{$k->route_from}][{$k->route_to}]">{$k->route_from} To {$k->route_to},{$k->bus_time}</option>
    

    EDIT based on comment:

    Sorry, this will not work at all. I’m assuming you want the user to select some sort of route, and based on that you want to pass a particular value. The way a <select> works is this:

    In your HTML use this:

    <select name="test">
        <option value="1">First option</option>
        <option value="2">Second option</option>
    </select>
    

    Now, in PHP you can access the value that was submitted like this:

    $_REQUEST['test'] //this value will be 1 if the user 
                      //selected the first option, or 2 if 
                      //he selected the second
    

    You can use Arrays in the names of the input fields, so it would be possible to do something like this in HTML:

    <select name="test[1]">
        <option value="1">First option</option>
        <option value="2">Second option</option>
    </select>
    <select name="test[2]">
        <option value="1">First option</option>
        <option value="2">Second option</option>
    </select>
    

    Note that I used the array notation on the name attribute, not the value. Now you can do this in PHP:

    $_REQUEST['test'][1] //this value will be 1 if the user 
                         //selected the first option, or 2 if 
                         //he selected the second in the first
                         //drop down
    $_REQUEST['test'][2] //this value will be 1 if the user 
                         //selected the first option, or 2 if 
                         //he selected the second in the second
                         //drop down
    

    So what you’re doing, using arrays in the value attribute will not work. You could do something like this:

    <select name="bus_info">
        <option value="{$k->bus_id},{$k->route_from},{$k->route_to}">{$k->route_from} To {$k->route_to},{$k->bus_time}</option>
    </select>
    

    And then in PHP:

    $values = explode($_REQUEST['bus_info']);
    //now $values is an array with 3 elements, the ID, the route_from and route_to
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have HTML that looks like this: <form id=kinodForm> <input type=text name=element[5] value=krispy kreme
I have some html form like that: ... <input type="text" id="color" name="color" value="" placeholder="Color"
Let's say I have an html form. Each input/select/textarea will have a corresponding <label>
I have an HTML form - with PHP, I am sending the data of
I have a html form on DNN website. This form will submit data to
I have a html form ... While submitting that form, I am calling one
Essentially, I have a dynamically generated local HTML form that I would like to
We have HTML form which will allow french alphabets. So we have added validation
html form will have questionaire students fill out the questionaire and submit them the
I have a HTML form, and I have a Controller Action that accepts 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.