need help with mysterious array initialization

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brixton
    New Member
    • Nov 2006
    • 35

    need help with mysterious array initialization

    Hello,

    sorry for the cryptic thread subject :)

    I'm examining some code at the moment and have come across the following:
    Code:
    $genders = array(
         'F' => __('Female', true),
         'M' => __('Male', true),
    );
    Normally, if I were to init an array I would simply do:
    Code:
    $genders = array(
         'F' => 'Female',
         'M' => 'Male'
    );
    So what's with the "__" and the boolean after the strings? This is part of a CakePHP app, if that is of importance.

    Thanks in advance!
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    I believe this is CakePHP's localization function.
    See 4.8.1 Internationaliz ing Your Application in the CakePHP manual.

    Comment

    • Dheeraj Joshi
      Recognized Expert Top Contributor
      • Jul 2009
      • 1129

      #3
      1. $genders = array(
      2. 'F' => 'Female',
      3. 'M' => 'Male'
      4. );
      Key must be within double quotes right.?

      "F" => 'Female';
      "M" => 'Male';

      Regards
      Dheeraj Joshi
      Last edited by Dheeraj Joshi; Dec 8 '09, 09:32 AM. Reason: Corrected grammer

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Key must be within double quotes right.?
        no.

        : )

        Comment

        • Dheeraj Joshi
          Recognized Expert Top Contributor
          • Jul 2009
          • 1129

          #5
          Yup... As soon as i posted it, i looked into php.net.......

          I should have looked it before... :)

          Regards
          Dheeraj Joshi

          Comment

          • brixton
            New Member
            • Nov 2006
            • 35

            #6
            Thanks Atli, just needed that nudge in the right direction :)
            Very nice documentation, overall.

            Comment

            Working...