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.

jurh
  • 420
  • 1
  • 4
  • 17

1 Answers1

1

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

$fileopslag[] = $filedir;
Imran Hossain
  • 606
  • 5
  • 16