Q:

How to display the key of key array in PHP?

This is the content of $records

If I wanted to display the "key" of this key array, how to code?
e.g. in first round of foreach loop I like to display
1 (key), 1 (id), 10 (price) and so on.
I would use $record['id'], $record['price'], but I don't know what to code to display the key?

A:

foreach ($records as $key => $record) {
    echo $key;
}

Check foreach in PHP manual for more info: http://php.net/manual/en/control-structures.foreach.php

A:

foreach($records as $key=>$record){
  echo "key: ".$key."</br>";
  echo "ID: ".$record['id']."</br>";
  echo "Price: ".$record['price']."</br>";
}

