title: Laravel If Else statement inside foreach
body: <p>I'm trying to use if/else statement inside my foreach loop. 
  With DomDocument i'm trying to find the description tag and the inside of the description tag. </p>
  
  <p>This works fine. When there is a description tag, it display's what's inside the description tag. If there is no description tag it displays: <code>No description found No description found No description found No description found</code>. Why does it show the error four times? How do i fix this?</p>
  
  <p>I'm using <strong>DomDocument and Laravel 5.4</strong></p>
  
  <p>Meta tag: </p>
  
  <pre><code>$meta = $dom-&gt;getElementsByTagName('meta');
  </code></pre>
  
  <p>My code: </p>
  
  <pre><code>@foreach ($meta as $node)
    @if($node-&gt;getAttribute('name')=='description') 
      {{$node-&gt;getAttribute('content'), PHP_EOL}}
        @else 
         {{'No description found'}}
    @endif
  @endforeach
  </code></pre>
  
  <p><strong>Edit, according to Muthu17:</strong></p>
  
  <p>I have almost written the same code as you. But the only problem is: It shows "No description found" all the time. Even if it finds the description tag, it show's the description tag init and "No description found".</p>
  
  <p>I've declared the <code>$showErrorMessage = 0;</code> in my controller.</p>
  
  <pre><code>@foreach ($meta as $node)
   @if($node-&gt;getAttribute('name')=='description') 
    {{$node-&gt;getAttribute('content'), PHP_EOL}}
     @else
      {!! $showErrorMessage == 1; !!}
     @endif
  @endforeach
  
  @if($showErrorMessage = 1)
   {{'No description found'}}
  @endif
  </code></pre>