Home >Backend Development >PHP Tutorial >Using php foreach with array_PHP tutorial
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