Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

For example i have the following script.

in this case i want to get the value of X1 and Y1 but the the exit() is not letting me to do so

please help thanks in advance and special thanks to Mark Setchell :P (if he sees this)

image link

 $im = imagecreatefromjpeg("omr.jpg");
for($x=0;$x<100;$x++)   {

    for($y=0;$y<100;$y++)   
                            {

$rgb = imagecolorat($im,$x,$y);
      $r = ($rgb >> 16) & 0xFF;
      $g = ($rgb >> 8) & 0xFF;
      $b = $rgb & 0xFF;
      if($r<128 && $g<128 && $b<128){
         printf("%d,%d: %d,%d,%d
",$x,$y,$r,$g,$b);
         exit;
                                    }
                            }
                        }

 for($x1=1170;$x1<1270;$x1++){

 for($y1=0;$y1<100;$y1++){

          $rgb = imagecolorat($im,$x1,$y1);

          $r1 = ($rgb >> 16) & 0xFF;
          $g1 = ($rgb >> 8) & 0xFF;
          $b1 = $rgb & 0xFF;
          if($r1<128 && $g1<128 && $b1<128){
          printf("%d,%d: %d,%d,%d
",$x1,$y1,$r1,$g1,$b1);
          exit;
        }
       }
    }

current output : 30,53: 123,119,118

Desired output : 30,53: 123,119,118

1217,55: 115,114,112

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
189 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use break 2; to break from two nested for loops and your next for loop for x1 and y1 will also execute.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...