Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

How can I filter my array by elements that are present in another array

$
0
0

I need to filter my array by elements that are present in another array.

More in details, I have two variables (arrays) in my Controller: one contains ALL users, another - users that are participated in evaluation. What I need is the third variable/or the list in twig (array) that will contain ALL THE REST - so I can choose from them out of a dropdown list for every evaluation (names that are already in evaluation won't appear in the dropdown list).

I am wondering now what is the best approach to do this.. Should I do this in twig or in controller?

Thank you!

twig:

<select name="user">   {% for user in users %}<option value="{{ user.idUser }}" label="{{ user.name }} ">     {% endfor %}</select>

controller:

    $evals = $this        ->getDoctrine()        ->getRepository(User::class)        ->findUserGroups();             // this is my own function (based on SQL query) from repository that searches for those who participated in evaluation    $users = $this        ->getDoctrine()        ->getRepository(User::class)        ->findAll();                    //this is a variable that contains ALL users (including those who already participated in evaluation)

Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>