title: Laravel Blade - Displaying array content
body: <p>I make calls to some APIs to fill up an array.  The end output is something like the following</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
      (
          [leadData] =&gt; Array
          (
              [LeadID] =&gt; 1232806
              [DateIdentified] =&gt; 21/04/2016
              [Client] =&gt; Prospect 1
              [LeadName] =&gt; Test
              [Owner] =&gt; Some Owner
              [Value] =&gt; 2160.00
              [Status] =&gt; 70%
          )
          [clientData] =&gt; Array
          (
              [BusinessStructure] =&gt; 
              [IsProspect] =&gt; No
          )
          [quoteData] =&gt; Array
          (
              [QuoteID] =&gt; Q0020
              [ProjectName] =&gt; Test
              [Amount] =&gt; 1800.00
              [AmountTax] =&gt; 360.00
              [AmountIncludingTax] =&gt; 2160.00
              [EstimatedCost] =&gt; 450.00
              [EstimatedCostTax] =&gt; 90.00
              [EstimatedCostIncludingTax] =&gt; 540.00
          )
          [customData] =&gt; Array
          (
              [0] =&gt; Array
              (
                  [Lead Type] =&gt; New 
              )
              [1] =&gt; Array
              (
                  [Month] =&gt; June
              )
          )
      )
      [1] =&gt; Array
      (
          [leadData] =&gt; Array
          (
              [LeadID] =&gt; 1230279
              [DateIdentified] =&gt; 19/04/2016
              [Client] =&gt; Bank1
              [LeadName] =&gt; test 3
              [Owner] =&gt; Some Owner
              [Value] =&gt; 36000.00
              [Status] =&gt; 50%
          )
          [clientData] =&gt; Array
          (
              [BusinessStructure] =&gt; 
              [IsProspect] =&gt; No
          )
          [quoteData] =&gt; Array
          (
              [QuoteID] =&gt; Q0016
              [ProjectName] =&gt; test 3
              [Amount] =&gt; 30000.00
              [AmountTax] =&gt; 6000.00
              [AmountIncludingTax] =&gt; 36000.00
              [EstimatedCost] =&gt; 0.00
              [EstimatedCostTax] =&gt; 0.00
              [EstimatedCostIncludingTax] =&gt; 0.00
          )
      )
  )
  </code></pre>
  
  <p>One thing to note is that sometimes not all of the information is there, simply because it is not available.  So you can see that Array 0 has some customData whereas Array 1 does not.  Other elements may not even have a quoteData section etc.</p>
  
  <p>So my blade template now has this information.  I basically want to show all the data, but if it is not available, to just show an empty cell.  So I have the following headers</p>
  
  <pre><code>&lt;table class="table table-bordered table-hover additionalMargin alignment"&gt;
      &lt;tr class="col-md-12 noPadding"&gt;
          &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Lead ID&lt;/th&gt;
              &lt;th&gt;Client Name&lt;/th&gt;
              &lt;th&gt;Is Prospect&lt;/th&gt;
              &lt;th&gt;Business Structure&lt;/th&gt;
              &lt;th&gt;Quote ID&lt;/th&gt;
              &lt;th&gt;Project Name&lt;/th&gt;
              &lt;th&gt;Amount&lt;/th&gt;
              &lt;th&gt;Amount Tax&lt;/th&gt;
              &lt;th&gt;Amount inc Tax&lt;/th&gt;
              &lt;th&gt;Cost&lt;/th&gt;
              &lt;th&gt;Cost Tax&lt;/th&gt;
              &lt;th&gt;Cost inc Tax&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Month&lt;/th&gt;
          &lt;/tr&gt;
          &lt;/thead&gt;
      &lt;/tr&gt;
      &lt;tbody&gt;
  
      &lt;/tbody&gt;
  &lt;/table&gt; 
  </code></pre>
  
  <p>However, within the tbody, what I am doing seems very messy, the only way I can seem to get data in the correct place is if I check everything e.g.</p>
  
  <pre><code>@if(is_array($leadArray))
          @foreach($leadArray as $array)
              &lt;tr&gt;
                   &lt;td&gt;
                       @if(!empty($array['leadData']))
                          {{ $array['leadData']['LeadID'] }}
                       @endif
                   &lt;/td&gt;
                   &lt;td&gt;
                       @if(!empty($array['leadData']))
                          {{ $array['leadData']['Client'] }}
                       @endif
                   &lt;/td&gt;
                   &lt;td&gt;
                       @if(!empty($array['clientData']))
                          {{ $array['clientData']['IsProspect'] }}
                       @endif
                   &lt;/td&gt;
                   &lt;td&gt;
                       @if(!empty($array['clientData']))
                          {{ $array['clientData']['BusinessStructure'] }}
                       @endif
                   &lt;/td&gt;
                  &lt;td&gt;
                      @if(!empty($array['quoteData']))
                          {{ $array['quoteData']['QuoteID'] }}
                      @endif
                  &lt;/td&gt;
                  &lt;td&gt;
                      @if(!empty($array['quoteData']))
                          {{ $array['quoteData']['ProjectName'] }}
                      @endif
                  &lt;/td&gt;
                  &lt;td&gt;
                      @if(!empty($array['quoteData']))
                          {{ $array['quoteData']['Amount'] }}
                      @endif
                   &lt;/td&gt;
                   &lt;td&gt;
                       @if(!empty($array['quoteData']))
                          {{ $array['quoteData']['AmountTax'] }}
                       @endif
                   &lt;/td&gt;
                   &lt;td&gt;
                       @if(!empty($array['quoteData']))
                           {{ $array['quoteData']['AmountIncludingTax'] }}
                       @endif
                   &lt;/td&gt;
                   &lt;td&gt;
                       @if(!empty($array['quoteData']))
                          {{ $array['quoteData']['EstimatedCost'] }}
                       @endif
                   &lt;/td&gt;
                   &lt;td&gt;
                       @if(!empty($array['quoteData']))
                          {{ $array['quoteData']['EstimatedCostTax'] }}
                       @endif
                   &lt;/td&gt;
                   &lt;td&gt;
                       @if(!empty($array['quoteData']))
                           {{ $array['quoteData']['EstimatedCostIncludingTax'] }}
                       @endif
                   &lt;/td&gt;
                  @if(!empty($array['customData']))
                      @foreach($array['customData'] as $data)
                              &lt;td&gt;
                                  @if(!empty($data['Lead Type']))
                                      {{ $data['Lead Type'] }}
                                  @endif
                              &lt;/td&gt;
                              &lt;td&gt;
                                  @if(!empty($data['Month']))
                                      {{ $data['Month'] }}
                                  @endif
                              &lt;/td&gt;
                      @endforeach
                      @else
                          &lt;td&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;/td&gt;
                  @endif
              &lt;/tr&gt;
          @endforeach
      @endif
  </code></pre>
  
  <p>Is there a neater way to do this?  Or is this my only option?</p>
  
  <p>Thanks</p>