There are two arrays:

$fdomain = $_POST['domains']; $fdomain = explode(PHP_EOL, $fdomain); $fip = $_POST['ip']; $fip = explode(PHP_EOL, $fip); 

How to get an array of them from the form:

 fdomain - fip 

I would be grateful for the help.

array data for example:

 array(3) { [0]=> string(8) "test.ru " [1]=> string(9) "site2.ru " [2]=> string(7) "test.in" } array(3) { [0]=> string(14) "111.11111.111 " [1]=> string(12) "2222.22.222 " [2]=> string(11) "333.333.333" } 

That is, the output needs such an array:

 array(3) { [0]=> string(*) "test.ru - 111.11111.111" [1]=> string(*) "site2.ru - 2222.22.222" [2]=> string(*) "test.in - 333.333.333" } 
  • @AntonShchyrov array, with values: test.ru - 111.11111.111 , etc. - iKey

3 answers 3

Understood:

 $new_arr = array(); $cnt = count($fdomain); for($i = 0; $i<$cnt; $i++) { $new_arr[] = $fdomain[$i].' - '.$fip[$i]; } 
     $merge = function ($domain, $ip) { return $domain . ' - ' . $ip; }; $data = array_map($merge, $fdomain, $fip); 
       $fdomain = $_POST['domains']; $fdomain = explode(PHP_EOL, $fdomain); $fip = $_POST['ip']; $fip = explode(PHP_EOL, $fip); $array = []; foreach ($fip as $key => $value) { $array [] = $fdomain[$key].' - '.$fip[$key]; } print_r($array);