So i want to do a php while loop atleast 10 times to see if the value changes via a curl request but i only want to loop through a max of 10 times
so when true and loop count is less then 10
any ideas
So i want to do a php while loop atleast 10 times to see if the value changes via a curl request but i only want to loop through a max of 10 times
so when true and loop count is less then 10
any ideas
It looks like you want a for loop with an extra condition... I assume you're using a variable to store whether it has changed (you said 'when true')..
$keepGoing = true;
for ($x = 0; $x < 10 && $keepGoing == true; $x++) {
    //your looping code.. 
}
The loop will run 10 times, or stop when $keepGoing is set to false.
Basically two possiblities:
for ( $i = 0; i < 10; i++ )
{
    if ( !CONDITION )
         break;
    // do something
}
$i = 10;
while ( CONDITION && $i-- > 0 )
{
    // do something
}
Use a for loop
for($i = 0; $i < 10; $i++)
{
    if($somethingChange)
        break;
}
$value = get_value(); // get initial value
$changed = FALSE;     // we've only checked once so it hasn't yet changed
$num_checks = 1;      // number of checks so far
$max_checks = 10;     // maximum number of checks
while ($num_checks < $max_checks && !$changed) {
    // check again
    $num_checks++;
    $new_value = get_value();
    // has it changed?
    $changed = ($new_value != $value);
}
if ($changed) {
    echo "value changed from $value to $new_value on check $num_checks\n";
} else {
    echo "value stayed as $value; checked $num_checks times\n";
}
simple
$max = 10;
while($max--){
    if(something_is_ok())
        break;
}