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

  • Home
  • SEARCH
  • 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 8800101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:29:50+00:00 2026-06-14T00:29:50+00:00

I want to add new values in php array by html form. I wrote

  • 0

I want to add new values in php array by html form. I wrote something like following in php:

$b=array();
$b[]=$_POST['unos'];

and something like this in html:

<form action="?" method="post">
<input type="number" name="unos"  id="unos">
</form> 

And that code do the job, but only for one value. In other words, I am asking how to import more than one value in array. I add value=”3″

in html input form, but that does not works, of course, or it is just one part of the answer. How to tell php to allow adding more than one value in array via html form?

UPDATE:

I want to import more values in one input field, that would be separated with “,” for example, or whatever convention is.

UPDATE:

 <?php
 $unos=array();
 $unos[]=$_POST['unos'];
 $rezultat=count($unos); /*number of n's*/
 $zbir=array_sum($unos); /*total sum of n's*/
 $av=$zbir/$rezultat;    /*average value of n's*/
 echo "average value is $av</br>";
 }
 ?>
 <form action="?" method="post">
 <input type="number" name="unos"  id="unos">
 <input type="submit" value="Submit">
 </form> 

The code calculate average value of n’s. I am beginner and just want to know how to add values of arrays by user via html.The reason I wanted to know how one can do that in 1 input file is because I do not want to limit number of values with number of input fields. I want make that user can add values as many as he want. Sorry, my English is not perfect.

  • 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-06-14T00:29:51+00:00Added an answer on June 14, 2026 at 12:29 am
    <input type="number" name="unos[]">
    <input type="number" name="unos[]">
    <input type="number" name="unos[]">
    etc.
    

    The above is standard for pulling form values into an array, but, given your update:

    // Assuming "," separated values
       $unos = explode(",", $_POST['unos']);
    
       foreach ($unos as $item) {
           echo $item; // Do something with item
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert row for each day to add new values, and I
I want add new Feed item on entity persist and update. I write this
I want to add new obj of JSON like: 128: { Msg: [{ me:
I've following Grid to display data, now when I want to add new record
I want to add a new tab page for every newly opened form. Example:
PHP Code: $form = new Zend_Form(); $filters = array(new Zend_Filter_StringTrim()); $form->setElementFilters($filters); // <-- ISSUE
I have a array which contains values like this See below for script sample
I've a php language file, that lists values in an array. I want to
I am working with an NSOperationQueue and I want to add new NSOperations to
I want to test Add new item activity in my application. When user fills

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.