var variants = []
// Полный перебор всех размеров по одной из осей
for (var width = 1; width < letters_count; width++) {
var height = letters_count / width
if (Number.isInteger(height)) { // выбираем только те, где делится без остатка
variants.push({width: width, height: height, diff: Math.abs(width-height)})
}
}
// сортируем по минимальной разнице высоты и ширины
variants.sort((a, b)=>{
if (a.diff > b.diff) return 1
if (a.diff < b.diff) return -1
return 0
})
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 { ... }
Попробуйте поменять эти числа на сотню-другую, посмотрите что получится.