0

First please be gentle i am a beginner and only prectising,

I have a problem, i would like to get laravel's language files and edit their content.

My problem is what i dont really understand is the following

i have a functions what returns the actual files, i have a variable what stores this

$directory =  File::files(self::$lang_path.$code);

id i die and dump i get back the following

array(3) {
  [0]=>
  string(26) "app/lang/en/pagination.php"
  [1]=>
  string(25) "app/lang/en/reminders.php"
  [2]=>
  string(26) "app/lang/en/validation.php"
}

all fine, but if foreach it and die and dump

$directory =  File::files(self::$lang_path.$code);

    foreach ($directory as $files) 
    {
        dd($files);

    }

i just get back string(26) "app/lang/en/pagination.php"

could please tell me what i am doing wrong?

and the problem is i need it because i will need nested foreac

like

$directory =  File::files(self::$lang_path.$code);

        foreach ($directory as $files) 
        {
            foreach ($files as $file) 
            {
                // preform more stuff
            }

        }

and idont understand what iam doing wrong, could please someone give me a hint?

2 Answers 2

2

The dd (dump and die) function kills script execution - It therefore will only show the first item in the array before calling die().

Use var_dump instead.

If you're curious, you can see the function definition here.

Sign up to request clarification or add additional context in comments.

Comments

0

Alternatively, you can use my helper function.

function printPre($array, $string = false, $exit = true){

if(env('APP_ENV')=='local') {

    if($string){
        print_r($array, $string);
    }
    else{
        echo '<pre>';
        print_r($array);
        echo '</pre>';
    }
    if($exit)
        exit;
}

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.