0

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 doesn't get added.

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

Why isn't $project['image_dimensions'] getting added to $project?

2
  • 1
    Another one stackoverflow.com/q/10121483/1741542 Commented Nov 20, 2016 at 17:58
  • thank you second reference was the solution!, if you want to be the answer of this question write one and ill accept it :) Commented Nov 20, 2016 at 18:02

1 Answer 1

1

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;
}
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.