Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67411

Remove Duplicates from Echoing in PHP Foreach

$
0
0

I'm trying to use get the response headers using PHP.

Here's my current code:

foreach ($headers as $name => $value) {
  foreach ($value as $key => $moreinfo) {
    echo "$name === $moreinfo \n";
  }
}

I basically just don't want there to be multiple $name entries.

For example, I'm currently seeing this being echoed:

date === Sun, 03 Nov 2019 03:03:11 GMT 
date === Sun, 03 Nov 2019 03:03:11 GMT 
via === 1.1 varnish 
via === 1.1 varnish 
connection === keep-alive 
x-served-by === cache-bur17530-BUR 
x-served-by === cache-bur17548-BUR 

I would want it changed to just showing this:

date === Sun, 03 Nov 2019 03:03:11 GMT 
via === 1.1 varnish 
connection === keep-alive 
x-served-by === cache-bur17548-BUR 

Is there anything that could just be modified in the foreach to make this happen?


Viewing all articles
Browse latest Browse all 67411

Trending Articles



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