Skip to content
Advertisement

How i can echo only the header that i want? php

So i want to echo only a header not all of them.

An example the Server header which contains the information what server it is.

Or X-powered: PHP/version header.

I know i can use print_r($headers[“0”]); but the problem here is i will don’t know what number is that header exactly.

JavaScript

how i can print only the header i want without knowing the array number.

JavaScript

Advertisement

Answer

Iterate over your $headers and search for a substring in every header:

JavaScript

Using second parameter of get_headers as 1, will even give you an array, so you can check if required key exists with isset or array_key_exists:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement