Welcome Guest, Not a member yet? Register   Sign In
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',
        ],
]; 
Thread about my project that is using CodeIgniter:
Reply
#2

(This post was last modified: 02-02-2021, 01:05 PM by Acuru.)

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
Thread about my project that is using CodeIgniter:
Reply




Theme © iAndrew 2016 - Forum software by © MyBB