Get the key without the value in foreach loop


I am wondering if it is possible to get the key without the value in foreach loop. I don't use the value anywhere in the code so I would like to exclude it.

so instead of this foreach($array as $key => $value) {

having something like this foreach($array as $key) {


foreach(array_keys($array) as $key) {
  echo $key;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment


Get value of hash key without loop

Get object value by key without using loop

PHP check array object key value without using loop/foreach

JSON forEach get Key and Value

foreach loop get the value of an element

On the Foreach Loop Get Previous Value

How to combine two multi-dimensional arrays based on key value pairs without nested foreach loop?

PHP - value of previous key in foreach loop

Create array in foreach, key to be the first value in loop

Add value to existing array key in foreach loop

PHP foreach loop key value error

get the next key in array in php foreach loop

Get value from IEnumerable foreach loop

How to get unique value in foreach loop

Get value of defined variable which is in forEach loop

XSLT Get the node value by index in foreach loop

How to get even key value from array in PHP without using any loop

How to get the key, value and index in a Dictionary loop?

foreach loop on 3 key value array at the same time

Can't set key value array to an array using foreach loop

foreach loop to print key value pairs while imploding the nested arrays

Adding key value pair to object inside forEach loop

How foreach loop work to sum value of same key in associative array

How to implode array with key and value without foreach in PHP

PHP return the key of assoiative array by value without using foreach

How to get the lowest value without knowing the key

Dictionary get value without knowing the key

How to get key of multidimensional array in foreach loop using php?

Trying to get key in a foreach loop to work using blade

TOP Ranking

  1. 1

    How can I create a column whose entries depend on the contents of a column in another table?

  2. 2 port in URL

  3. 3

    How to display items using sessions

  4. 4

    BigQuery - concatenate ignoring NULL

  5. 5

    no applicable method for 'mutate_' applied to an object of class "c('integer', 'numeric')"

  6. 6

    How i extract text from a model dialog in selenium?

  7. 7

    x no applicable method for 'tbl_vars' applied to an object of class "c('double', 'numeric')"

  8. 8

    AirflowException: Celery command failed - The recorded hostname does not match this instance's hostname

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    Most efficient regex for checking if a string contains at least 3 alphanumeric characters

  11. 11

    using excel range find return Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

  12. 12

    redirect your computer port to url

  13. 13

    Can't create database with Symfony 4.1 : could not find driver

  14. 14

    How to fix "Exception evaluating SpringEL expression" error after submitting a variable Spring/Thymeleaf

  15. 15

    A python function to get the maximum value of a specific column, given a string that represents a table in CSV format

  16. 16

    Double spacing in rmarkdown pdf

  17. 17

    Uploading Files on production server returns either CORS error or POST 400 Bad Request using Apollo-Graphql

  18. 18

    Android Kotlin Unit test failing with io.mockk.MockKException: no answer found for

  19. 19

    Change Model input_shape but got an : ValueError: Input 0 of layer dense_44 is incompatible with the layer

  20. 20

    Formik, Yup - How to check is Decimal number

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class