Answers for "foreach index and value php"

PHP
-1

php get index in foreach

$array = array('a', 'b', 'c');
foreach ($array as $letter=>$index) {

  echo $letter; //Here $letter content is the actual index
  echo $array[$letter]; // echoes the array value

}//foreach
Posted by: Guest on September-18-2021

Browse Popular Code Answers by Language