Home  >  Article  >  Backend Development  >  PHP one-dimensional array loop traversal implementation method

PHP one-dimensional array loop traversal implementation method

墨辰丷
墨辰丷Original
2018-05-24 09:53:574647browse

A simple example of PHP looping a one-dimensional array, first convert the string into an array according to certain rules, and then traverse the output. It is actually a very simple method

A simple PHP An example of looping a one-dimensional array is to first convert the string into an array according to certain rules, and then traverse the output. It is actually a very simple method, because a two-dimensional array structure diagram I recently made was a headache, so I can't remember how to perform traversal output for a while. The simple example code is as follows:

foreach traverses the array

 $value) { 
    echo $key.'='.$value.'
'; } ?>

Traverses the associative array

'Lilia','Gender'=>'female','Age'=>'23','School'=>'Peking University'); 
   foreach ($userList as $key => $value)  
  { 
    echo $key.'='.$value.'
'; } ?>

The above is the entire content of this article, I hope it will be helpful to everyone's study.


Related recommendations:

How to automatically load classes in PHP

PHP’s middleware ICE

PHP Two-dimensional array deduplication or statistics based on a certain field

The above is the detailed content of PHP one-dimensional array loop traversal implementation method. For more information, please follow other related articles on the PHP Chinese website!

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