Hi, I’m trying to solve BEADS - Glass Beads in PHP, in my IDE it works, but when I’m trying to submit to spoj I do get an error wrong. Please some help would be appreciated.
Edit:
Fixed the input stuck at a max time limit 
fscanf(STDIN, “%d\n”, $n);
$testCases = [];
for ($i = 0; $i < $n; $i++) {
fscanf(STDIN, “%s\n”, $strings);
$testCases[] = $strings;
}
$valuesOfLowestLexi = 0;
function check($case, $valuesOfLowestLexi, $iteration, $n)
{
for ($i = 0; $i < $n; $i++) {
if ($case[$valuesOfLowestLexi] < $case[$iteration]) {
return false;
} else {
if ($case[$valuesOfLowestLexi] > $case[$iteration]) {
return true;
}
}
$valuesOfLowestLexi = ($valuesOfLowestLexi + 1) % $n;
$iteration = ($iteration + 1) % $n;
}
return true;
}
foreach ($testCases as $case) {
for ($i = 1; $i < strlen($case); $i++) {
if (check($case, $valuesOfLowestLexi, $i, strlen($case))) {
$valuesOfLowestLexi = $i;
}
}
echo $valuesOfLowestLexi + 1 . PHP_EOL;
}