• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting array length from language file

#1
I am making quiz feature for my website based on language files, I want to have 1 correct answer and multiple false for any one question, but number of wrong answer is not constant between questions. How can i get array length of wrong questions from language file, without needing to store number of wrong answers somewhere else. My language file has structure like bellow:
PHP Code:
return [
    
=> [
        
'queston' => 'Is there question here?',
        
'correct' => 'Yes!',
        
'falses' => [
            
'Nope',
            
'Uh... no?',
            
'It is somwhere else',
            
'I like bananas'],
        ],
    
=> [
        
'queston' => 'Do you like bananas?',
        
'correct' => 'Yes!',
        
'falses' => [
            
'No',
        ],
]; 
Reply

#2
Ok, after looking into language class, and some experimenting, I figured it out, and it is much simpler as i expected Big Grin In case someone will be searching for it, bellow is answer (for example as above, assuming file is named Quizzes):

PHP Code:
$lines count(lang('Quizzes.1.falses')); 

Yea... i feel little dumb Big Grin
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.