Thom
Thom

Reputation: 621

PHP Get values from unknown numbers of text input

I have a div in my page called .highlights.
In this div I have a unknown numbers of text input(<input type="text" />). It can range from 0 to unknown.

When someone clicks at submit, I want to store in PHP all the values of the inputs, into one variable called myHighlights. The values must be seperated by ;

Upvotes: 0

Views: 93

Answers (3)

Leo T Abraham
Leo T Abraham

Reputation: 2437

if($_POST)
{    
    $myHighlights = implode(';',$_POST);
    print_r($myHighlights);
}

Upvotes: 0

jogesh_pi
jogesh_pi

Reputation: 9782

<input type="text" name="unlimited[]" />

if( isset($_POST['submit_button']) ) {
   // Skip blank values
   $unlimited = array_filter( $_POST['unlimited'] );
   $myHighlights = implode(';', $unlimited);
}

Upvotes: 1

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146460

To begin with, you'll have to assign names to the controls so they get sent together with the rest of of the form. Please have a look at the How do I create arrays in a HTML <form>? entry of the PHP FAQ for a nifty trick.

Upvotes: 1

Related Questions