0

I have the below code but I'm not getting all the results from the array

  foreach ($reviewers as $login_name => $common_name) {
    $allowed_values = [
      '' => 'All',
      $login_name => $common_name,
    ];
  }
1
  • 3
    You are overwriting the array on each loop Commented Feb 28, 2022 at 20:34

1 Answer 1

1

You overwrite the entire array each time through the loop. Just add the key and value in the loop:

  $allowed_values = ['' => 'All'];

  foreach ($reviewers as $login_name => $common_name) {
      $allowed_values[$login_name] = $common_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.