if ($y < $height - 1) ...
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.example.com/test.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'login' => 'vasya',
'password' => 'mypassword'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
var_export($server_output);
// further processing ....
if ($server_output == "OK") { ... } else { ... }
да хоть больше тысячитормознутые странички никогда не встречались?
https://codepen.io/anon/pen/mByWNv?editors=1010
Там же циклы только при добавлении обработчика и при обнулении чем вам break поможет?