Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

image - How to continue a php script after using exit() / die()

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

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

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...