2

Using PHP CodeIgniter, I have a form with multiple numeric inputs, each with a unique name:

<td><input type="number" style= 'width: 40px' name="order<?php echo $bannerId?>" value="<?php echo $banner->b_order; ?>"</td>

I can access the field value using:

$_POST['order'];

but is there a way in PHP to access the name attribute itself, instead of the value?

So in the controller I can use the $bannerId variable echoed in the form.

3
  • 1
    if you display the keys of $_POST ? array_keys() php.net/manual/fr/function.array-keys.php Commented Nov 18, 2016 at 12:36
  • $this->input->post[ 'banner_id' ]; Commented Nov 18, 2016 at 12:37
  • @Blinkydamo => unique names seem dynamicly set Commented Nov 18, 2016 at 12:39

1 Answer 1

2

Using array keys you could get all the 'names' and then loop over them:

array_keys($_POST)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.