dongxianrang9269
2017-04-11 00:16 阅读 28
已采纳

PHP / Asterisk AGI计算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);
    }
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    doumaqing6652 doumaqing6652 2017-04-11 03:17

    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);
       }
    }
    
    点赞 评论 复制链接分享

相关推荐