我在config
中有一个名为etc/
1.conf
个文件
这是内容..
[2-main]
exten => s,1,Macro(speech,"hi {$VAR1} how is your day going?")
exten => s,4,Macro(dial,2,555555555)
exten => s,2,Macro(speech,"lkqejqe;j")
exten => s,3,Macro(speech,"hi there")
exten => s,5,Macro(speech,"this is a test ")
exten => s,6,Macro(speech,"testing 2")
exten => s,7,Macro(speech,"this is a test")
exten => 7,1,Goto(2-tester2,s,1)
exten => 1,1,Goto(2-aa,s,1)
[2-tester]
[2-aa]
exten => 1,1,Goto(2-main,s,1)
如何阅读语音之间的内容,例如..
exten => s,6,Macro(speech,"testing 2")
从那里得到"testing 2"
。
提前谢谢!
答案 0 :(得分:2)
如果我理解正确,这个
$text = file_get_contents('/etc/1.conf');
preg_match_all('/speech,"(.*)"/', $text, $match);
将使用语音行中的所有文本填充$match
数组。具体来说,$match[1]
将是一个仅包含引号内字符串的数组,因此您可以这样做是为了方便和可读:
$speeches = $match[1];
echo $speeches[0]; // or 1 or 2 etc.