0

I have created an empty array above my foreach loop. I want to add my variable $filedir to my array until the foreach loop finish.

This is my code:

$fileopslag = array();
foreach($searchdoc as $searchdocument){
$filedir = 'd:\Documentatie/'.$searchdocument->pagename; 
$fileopslag = $filedir; 
}

When I do this, it adds the variable one time to my array.

When I show my output with var_dump, I see this:

"string(23) "d:\Documentatie/16.html", one string, but not a list.

0

1 Answer 1

1

you are not storing data into array rather directly updating by a string in each iterration in the loop.
do

$fileopslag[] = $filedir;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.