Thanks for your help.
Still struggling with both methods. Here is what I’m posting:
[PHP]
Array
(
[url1] => /admin
[useragent1] => Googlebot
[action1] => Allow:
[url2] => /account
[useragent2] => Googlebot
[action2] => Allow:
[url3] => /includes
[useragent3] => *
[action3] => Allow:
[submit] => Submit values
[items] => 3
)
[/PHP]
With your code Redscouse, here is my output:
[PHP]
Array
(
[0] => Array
(
[url1] => /admin
[useragent1] => Googlebot
[action1] => Allow:
[url2] => /account
[useragent2] => Googlebot
[action2] => Allow:
[url3] => /includes
[useragent3] => *
[action3] => Allow:
[submit] => Submit values
[items] => 3
)
)
Array
(
[0] => Array
(
[url1] => /admin
[useragent1] => Googlebot
[action1] => Allow:
[url2] => /account
[useragent2] => Googlebot
[action2] => Allow:
[url3] => /includes
[useragent3] => *
[action3] => Allow:
[submit] => Submit values
[items] => 3
)
)
[/PHP]
With Lewisstevens1’s code I did this:
[PHP]
<?php
if (isset($_POST['submit'])){
$count = $_POST['items'];
$useragent = $_POST;
$values = array();
for( $i = 1; $i <= $count; $i++ ){
// $string = "User-Agent: " . $_POST['useragent'.$i] . PHP_EOL . $_POST['action'.$i] . $_POST['url'.$i] . PHP_EOL;
// echo $string;
//echo $useragent['useragent'.$i] . "
";
if(!in_array($useragent['useragent'.$i],$values)){
array_push($values,$useragent['useragent'.$i]);
print '
';
print_r($values);
print '
';
/* DO THE REST HERE */
}
}
}
?>
[/PHP]
Which produced this:
[PHP]
Array
(
[0] => Googlebot
)
Array
(
[0] => Googlebot
[1] => *
)
[/PHP]
In the form, I use JS to add a new row to the form and add a count to the post which is called ‘items’, I wouldn’t normally do this as I’ve never had the need to add elements to a form dynamically before, I think that’s why I’m a little stuck.
Where can I go from there?
Cheers guys!