PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Obtaining translations for "yes" and "no"

Frequently, programs need to solicit a "yes" or "no" response from the user. Use getQuestion() to obtain an array containing the correct word(s) or regex strings to use for prompting the user in a particular $locale (defaults to the current object's locale). The returned array will contain the following information :

  • yes and no: A generic string representation for yes and no responses. This will contain the first and most generic response from yesarray and noarray.

    yesarray and noarray: An array with all known yes and no responses. Several languages have more than just two responses. In general this is the full string and its abbreviation.

    yesexpr and noexpr: A generated regex which allows you to handle user response, and search for yes or no.

All of this information are of course localized and depend on the set locale. See the following example for the information you can receive:

Example 559. getQuestion()

<?php
$locale 
= new Zend_Locale();
// Question strings
print_r($locale->getQuestion('de'));

- - - 
Output - - -

Array
(
    [
yes] => ja
    
[no] => nein
    
[yesarray] => Array
        (
            [
0] => ja
            
[1] => j
        
)

    [
noarray] => Array
        (
            [
0] => nein
            
[1] => n
        
)

    [
yesexpr] => ^([jJ][aA]?)|([jJ]?)
    [
noexpr] => ^([nN]([eE][iI][nN])?)|([nN]?)
)

Note

Until 1.0.3 yesabbr from the underlaying locale data was also available. Since 1.5 this information is no longer standalone available, but you will find the information from it within yesarray.

Zend Framework