Jur Hillebrink Jur Hillebrink - 5 months ago 25
PHP Question

Combine array and variable php

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.


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

$fileopslag[] = $filedir;