O
O
Optimus2015-07-10 20:32:55
PHP
Optimus, 2015-07-10 20:32:55

How to extract the keys of an array?

There is an associative array where the keys are Cyrillic values, and the accompanying values ​​are numbers.

array(288) {
  ["еда"]=>
  int(4)
  ["вода"]=>
  int(4)
  ["энергия"]=>
  int(4)
  ["топливо"]=>
  int(3)
  ["лес"]=>
  int(3)
  ["нефть"]=>
  int(3)
  ["дрова"]=>
  int(3)
  ["руда"]=>
  int(2)
...
}

I'm stupid and can't figure out how to get the first 4 keys from this array. Those. I am interested in 4 words in this example: food, water, energy, fuel. Tried foreach but instead of keys, it gives me their values ​​(numbers).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2015-07-10
Pyan @marrk2

array keys

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question