简体   繁体   中英

PHP / Asterisk AGI Count number of digits from GetData

I am attempting to count the number of digits that a caller inputs when prompted. If the number of digits input does not equal 10, I would like it to return to the beginning of the file. If the number of digits input does equal 10 I would like it to continue executing the program. With the code below, no matter the callers input, it always goes back to the beginning. Can anyone give me some insight here?

begining: {

    $agi->stream_file('file1');
    $result = $agi->get_data('beep', 6000, 10);
    $numlength = mb_strlen(utf8_decode($result));
    if ($numlength < 10){
            goto begining;
    }

    else {
        $number= $result['result'];
        $agi->verbose("Number: ".$number);
    }
}

You need to specify which part of the array you are counting. Add ['result'] to your $result variable.

$agi->stream_file('file1');
$result = $agi->get_data('beep', 6000, 10);
$numlength = mb_strlen(utf8_decode($result['result']));
   if ($numlength < 10){
           goto begining;
   }

   else {
       $number= $result['result'];
       $agi->verbose("Number: ".$number);
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM