本文整理汇总了PHP中AppletInstance::assocKeyValueCombine方法的典型用法代码示例。如果您正苦于以下问题:PHP AppletInstance::assocKeyValueCombine方法的具体用法?PHP AppletInstance::assocKeyValueCombine怎么用?PHP AppletInstance::assocKeyValueCombine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppletInstance
的用法示例。
在下文中一共展示了AppletInstance::assocKeyValueCombine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Response
<?php
$response = new Response();
/* Fetch all the data to operate the menu */
$digits = isset($_REQUEST['Digits']) ? $_REQUEST['Digits'] : false;
$prompt = AppletInstance::getAudioSpeechPickerValue('prompt');
$invalid_option = AppletInstance::getAudioSpeechPickerValue('invalid-option');
$repeat_count = AppletInstance::getValue('repeat-count', 3);
$next = AppletInstance::getDropZoneUrl('next');
$selected_item = false;
/* Build Menu Items */
$choices = (array) AppletInstance::getDropZoneUrl('choices[]');
$keys = (array) AppletInstance::getDropZoneValue('keys[]');
$menu_items = AppletInstance::assocKeyValueCombine($keys, $choices);
$numDigits = 1;
foreach ($keys as $key) {
if (strlen($key) > $numDigits) {
$numDigits = strlen($key);
}
}
if ($digits !== false) {
if (!empty($menu_items[$digits])) {
$selected_item = $menu_items[$digits];
} else {
if ($invalid_option) {
$verb = AudioSpeechPickerWidget::getVerbForValue($invalid_option, null);
$response->append($verb);
$response->addRedirect();
} else {
$response->addSay('You selected an incorrect option.');
$response->addRedirect();
示例2: get_instance
<?php
$ci =& get_instance();
/* Get the body of the SMS message */
$body = isset($_REQUEST['Body']) ? trim($ci->input->get_post('Body')) : null;
$body = strtolower($body);
$prompt = AppletInstance::getValue('prompt');
$keys = AppletInstance::getValue('keys[]');
$responses = AppletInstance::getValue('responses[]');
$menu_items = AppletInstance::assocKeyValueCombine($keys, $responses, 'strtolower');
$response = new TwimlResponse();
/* Display the menu item if we found a match - case insensitive */
if (array_key_exists($body, $menu_items) && !empty($menu_items[$body])) {
$response_text = $menu_items[$body];
} else {
/* Display the prompt if incorrect */
$response_text = $prompt;
}
$response->sms($response_text);
$response->Respond();
示例3: isset
<?php
$body = isset($_REQUEST['Body']) ? trim($_REQUEST['Body']) : null;
$keys = (array) AppletInstance::getValue('keys[]');
$responses = (array) AppletInstance::getDropZoneUrl('responses[]');
$menu_items = AppletInstance::assocKeyValueCombine($keys, $responses);
$next = AppletInstance::getDropZoneUrl('invalid-option');
$response = new TwimlResponse();
foreach ($menu_items as $regex => $redirect) {
if (!empty($regex) && preg_match("/" . $regex . "/i", $body)) {
$next = $redirect;
break;
}
}
if (!empty($next)) {
$response->redirect($next);
}
$response->respond();