FutureCake FutureCake - 1 year ago 75
PHP Question

element doesnt get added to associative array php

I have the following code that loops trough an array called projects and each project is an associative array. Then i get the image properties and then i want to add a new element to this associative array with the image properties. but it doesnt gets added...

foreach ($projects as $project) {
$image_dimensions = array(getimagesize('data/'.$project['base_image']));
$project['image_dimensions'] = $image_dimensions;

Why isnt
getting added to

Any help is appreciated!

Answer Source

Please try with this one. You need to add with all projects all key.

            foreach ($projects as $key => $project) {
            $image_dimensions =array(getimagesize('data/'.$project['base_image']));
            $projects[$key]['image_dimensions'] = $image_dimensions;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download