条件=真时的Php循环[关闭]

I have a php file which basically reads a page using JSON and a variable is returned to it (pending/paid/expired). now my simple requirement is if the returned variable is paid/expired the respective actions for them should be taken and the loop should not be repeated but if the response is pending the code should recheck after 10 seconds. A similar cycle then happens again and so on till the loop is stopped(by receiving either a expired/paid response.

here is the code i prepared for it using the examples i found at various places but this doesnt seem to work correctly.. pls guide..

    while($end==0) {        
        $json = file_get_contents('http://old.kbourbaki.com/xlisteningpageprestashop.aspx?yyyyyyy');
        $obj = json_decode($json);
        $result=$obj->response;
        echo($result);
        if ($result=='paid') {
            p('Order Successfull');
            $end=1;
        } elseif ($result=='expired' ) {
            p('status = expired');
            $end=1;//ex

    } else {
        d('status = Pending');
        sleep(10);
    }
}

CODE UPDATED extra '{' removed

You have one too many curly braces. The proper elseif and else block should look like this

} elseif ($result=='expired' ) {
    p('status = expired');
    $end=1;//ex
} else {

It would help you a lot if you properly formatted your code.

You close the IF condition before the last ELSE just delete the closing clasp.

if($result=='paid'){
    p('Order Successfull');
    $end=1;
}else if($result=='expired'){
    p('status = expired');
    $end=1;//ex
}else{
    d('status = Pending');
    sleep(10);
}