for for if matrix matrix break if break

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
for($x=0;$x<$w;$x++){
for($y=0;$y<$h;$y++){
if($matrix[$x][$y] == 1){
$matrix[$x][$y] = 2;
$c = 1;
break;
}
}
if($c){
$c = 0;
break;
}
}