Playback interruption in Asterisk

Hi,
We have different voice menus in our application,we are using php scripting.Wanted to know how the playback of these menus can be interrupted by pressing the DTMF keys?
For eg:we have a voice menu which asks the user to enter his Date of Birth.The user must be able to enter his date of birth even in between when the menu is being played.How to do that?

I saw in Dial plan there is an application called as Background application,which does this work.Is it possible to use Background application in our PHP scripts? Or is there any other method to do this?Please advice

If you are using PHPAGI you can use get_data(): “array, get_data (string $filename, [integer $timeout = NULL], [integer $max_digits = NULL])”

HI,
We are currently using get data only.We are using as below

$res = $agi->stream_file($voice_menus.’/anyblog_id’);fflush($agi->out); // Voice menu which asks for a 4 digit id to be entered

$result = $agi->get_data(‘beep’,8000,4); // Get data gets the 4 digit id after the beep.

But the get data takes the data after the playback is finished,Here in this case the playback cannot be interrupted.
I want to get the data during the playback of the voice menu only.
How to do this?

in you get_data instead of playing a beep, play the desired file.

Thank you very much.Its working.