9

I'm trying to fill an array with my foreach loop, but I don't get it to work. What am I doing wrong?

$a = array();

$activities = Project::getProjectnames($_DB, $projectnaam);
if(!empty($activities)) {
    foreach($activities as $k => $v) {
          $a .= array_fill($v['name']);
    }
}

All I get back is the string Array...

1 Answer 1

22

you're concatenating a string there. You need to push the item into the array.

   foreach($activities as $k => $v) {
          $a[] = $v['name'];
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.