Home  >  Article  >  Backend Development  >  Small example of php each() function

Small example of php each() function

WBOY
WBOYOriginal
2016-07-25 08:56:17806browse
  1. //Learn how to use each() function

  2. $prices=Array('Tries' => 100, 'Oil' => 10, 'Spank Plugs' => 4)

  3. while($elements = each($prices)){

  4.  echo $elements['key']; //echo $elements[0];
  5.  echo " - ";
  6.  echo $elements['value']; //echo $element[1];
  7.  echo "
    ";
  8. }

Copy code

Output results : Tires-100 Oil-10 Spank Plugs-4



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn