Why code goes to infinite loop? (
    <?php
    $mines = 10;
    
    ####
    for($x=1; $x<=9; $x++) {
    	for($y=1; $y<=9; $y++) {
    		$minefield[$x][$y] = 0;
    	}
    }		
    
    for($i=0; $i<$mines; $i++) {
    	$randx = rand(1, 9);
    	$randy = rand(1, 9);
    		
    	if($minefield[$randx][$randy] == 'X') {
    		$i--;
    	} else {
    		$minefield[$randx][$randy] = 'X';
    	}
    }

What's i doing wrong?
Why code goes to infinite loop? (
===

    <?php
    $mines = 10;
    
    ####
    for($x=1; $x<=9; $x++) {
    	for($y=1; $y<=9; $y++) {
    		$minefield[$x][$y] = 0;
    	}
    }		
    
    for($i=0; $i<$mines; $i++) {
    	$randx = rand(1, 9);
    	$randy = rand(1, 9);
    		
    	if($minefield[$randx][$randy] == 'X') {
    		$i--;
    	} else {
    		$minefield[$randx][$randy] = 'X';
    	}
    }

What's i doing wrong?