Title: How to make sql foreach loop by Laravel Query builder?
Tags: php;sql;laravel;postgresql;foreach
Question: I have an array. Can I send the values ​​in an array with one query and get a separate response for all arrays ...?
$regions:  array;
$result is laravel query result
['index'] is index from SQL
$data['persons'] = $reslut['index']['persons'];
$data['companies'] = $reslut['index']['companies'];
If I am sending an array to sql and can it return a separate value for each value? That is, the foreach loop should use sql and return the results to individual variables. Can I write in any of the indexes?
Comment: What `$regions`, `$reslut`? Please clarify your specific problem or add additional details to highlight exactly what you need.

Comment: Please review [ask]. Following that as a template for your question greatly enhances your chance of getting a satisfactory answer. In this particular case provide sample date - as text NO images - and the expected output from that data. Also what have you tried and what is incorrect with them?

Comment: if I am sending an array to sql and can it return a separate value for each value? That is, the foreach loop should use sql and return the results to individual variables. Can I write in any of the indexes?

Here is the accepted answer: You can query array data with a whereIn statement:
$results = Model75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0whereIn('your_field', $array)-&gt;get()
This will respond with a collection that contains multiple results. You can loop over them with for($results as $result){} or count them with $results-&gt;count()
.. But i'm not complete sure I did understand your question correct ;)


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:02/07/20', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<php><sql><laravel><postgresql><foreach>', 'Title': 'How to make sql foreach loop by Laravel Query builder?', 'ViewCount': 313, 'id': 60110679, 'user_AboutMe': None, 'user_AccountId': 17533589.0, 'user_DisplayName': 'Sherali Sherali', 'user_Reputation': 3.0, 'user_Views': 4.0, 'user_id': 12717163.0}}