title: Logic inside array
body: <p>I have an array with some static information for icons, basically a src key to where the icon is stored:</p>
  <pre><code>public static function content(array $data): array
  
  
  $content =      
        'components' =&gt; [
        
          [
              ...            
          ],
          
          [
                      'data' =&gt; [
                          'icons' =&gt; [
                              [
                                  'src' =&gt; '...',
                              ],
                              [
                                  'src' =&gt; '...',
                              ],
                              [
                                  'src' =&gt; '...',
                              ]
                          ]
                      ]
                  ],
          ...
          
           ];
  
          return $content;
          
  }
      
  
          
  </code></pre>
  <p>But I want to convert this static information to dynamic. I get several icons with &quot;$icons['data']['icon']&quot; and I want to list them in the same format above but dynamically, but like this doesn't work:</p>
  <pre><code>'data' =&gt; [
                          'icons' =&gt; [
  
                              foreach($icons['data']['icon'] as $icon){
                                  [
                                      'src' =&gt; $icon['src']
                                  ],
                              
                          ]
                      ]
          
  
          
  </code></pre>
  <p>Do you know what's the correct approach to achieve this? Thanks</p>