For loop

Greetings!


$accnum = $_POST['accnum'];
$copy = $_POST['copy'];

$previous_c = $copy[0];
$previous=$accnum[0];

for( $i = 0 ; $i<count($accnum) ; $i++)
{
	if ($i>=0)
	{
		if (empty($accnum[$i]))
		{
			$previous  = $acc;
			echo $acc = $previous + 1;
		}
		else
		{
			$previous=$accnum[$i];
			echo $acc = $accnum[$i];
		}
	}
	else
	{	
	echo $acc = $accnum[$i];
	}
}

What it does is that whenever the user input a value, ex. 1001, it will automatically add +1 to every value of my accnum. My problem is that, I want my $copy to do the same, I thought I’ll just follow the same thing and copy every code. But I did not get my desired result.

Any help? thank you.


$accnum = $_POST['accnum'];
$copy = $_POST['copy'];

$previous = $accnum[0];
$previous_c = $copy[0];

for( $i = 0 ; $i<count($accnum) ; $i++)
{
	if ($i>=0)
	{
		if ((empty($accnum[$i])) || (empty($copy[$i])))
		{
			$previous  = $acc;
			$previous_c  = $cop;
			 $acc = $previous + 1;
			 $cop = $previous_c + 1;

			echo $acc.'this is acc<br/>';
			echo $cop.'this is copy<br/>';
			
		}
		else
		{
			$previous = $accnum[$i];
			$previous_c = $copy[$i];
				
			 $acc = $accnum[$i];
			 $cop = $copy[$i];
		}
	}
	else
	{	
	$acc = $accnum[$i];
	}
}

When I generate 3 rows of textbox and put 100 value on $accnum and 1 in $copy, It display only 102,103 for accnum and 2,3 for copy. I need also to show the value I entered. Any how?

Can you give me a visual of what you want the behavior to be? I’m quite confused.