Home >Backend Development >PHP Tutorial >Using php foreach with array_PHP tutorial

Using php foreach with array_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:00:171051browse

Today’s tutorial will tell you a secret, that is, you cannot use associative arrays in PHP, as shown below. We cannot use foreach to display the specified value.

$gPurviews = array
(
array('key'=>'NEWS', 'name'=>'1231123'),
array('key'=>'PRODUCT', 'name'=>'1231 Management'),
array('key'=>'COMPANY', 'name'=>'Enterprise Information Management'),
         array('key'=>'JOB', 'name'=>'Recruitment Management'),
​​​ array('key'=>'ORDER', 'name'=>'Order Management'),
         array('key'=>'GUESTBOOK', 'name'=>'Message Management'),
​​​ array('key'=>'USER', 'name'=>'Registered User Management'),
array('key'=>'USER', 'name'=>'User Management')
);
foreach($gPurviews as $v1){
foreach($v1 as $tarray){
                   echo $tarray;                                                                                           }
?>

Okay, let’s look at the example


http://www.bkjia.com/PHPjc/445513.html

truehttp: //www.bkjia.com/PHPjc/445513.htmlTechArticleToday this tutorial will tell you a secret, that is, associative arrays cannot be used in php, as shown below , we cannot use foreach to display the specified value. $gPurviews = array ( array...
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