I'm trying to add an array to an associative array.
$contents = glob(DIR_IMAGE."catalog/Data_PDF/*");
$contents_pregged['name'] = preg_replace("(".DIR_IMAGE.")", "", $contents);
$contents_pregged['link'] = preg_replace("(catalog/Data_PDF/)", "", $contents_pregged['name']);
$data['contents'][] = array(
'name' => $contents_pregged['name'],
'link' => $contents_pregged['link']
);
The above example is within the controller and if i send the data alone it echos out all the files listed but i would like to use the arrays in an associative array so i can echo out the name and links using the example below.
{% for content in contents %}
<li><a href = "/image/{{content.link}}">{{content.name}}</a></li>
{% endfor %}
The responsive i get on the front end is Array
I have at the moment 3 files in the directory so the array should return 3 values
$data['contents'] = array(remove the []