PHP基础知识数组遗留问题
<?php
/**
* Created by PhpStorm.
* User: 刘高洋
* Date: 2016/7/14
* Time: 15:23
*/
header ( "Content-type:text/html;charset=utf-8" );
$myArr01 = array ( "车间01" , "车间02" , "车间03" , "车间04" );
$myArr02 = array ( "主管01" , "主管02" , "主管03" , "主管04" , "主管05" );
$myArr = array ( "车间经理" => $myArr01 , "主管经理" => $myArr02 );
//关联数组key-value 外循环打印出key值($myArr as $k => $value)‘车间经理’、‘主管经理’;
//内循环打印value($value as $v)
foreach ( $myArr as $key => $value ) {
// echo $key . "<br>";
// echo $value . "<br>";
/**
* Created by PhpStorm.
* User: 刘高洋
* Date: 2016/7/14
* Time: 15:23
*/
header ( "Content-type:text/html;charset=utf-8" );
$myArr01 = array ( "车间01" , "车间02" , "车间03" , "车间04" );
$myArr02 = array ( "主管01" , "主管02" , "主管03" , "主管04" , "主管05" );
$myArr = array ( "车间经理" => $myArr01 , "主管经理" => $myArr02 );
//关联数组key-value 外循环打印出key值($myArr as $k => $value)‘车间经理’、‘主管经理’;
//内循环打印value($value as $v)
foreach ( $myArr as $key => $value ) {
// echo $key . "<br>";
// echo $value . "<br>";
echo "key是:"." " . $key . "值是:" . $value . "<br>";}
//问题:为什么输不出value的值
//$myArr2 = array("name" => "刘高洋", "班级" => "网络142", "性别" => "男");
//foreach ($myArr2 as $key => $value) {
// echo "key是:" . $key . "值是:" . $value . "<br>";
//}
增加:
数组
1.一维数组:$myArr = array("1","2","3");(驼峰命名法)
2.关联数组:$myArr2 = array("","");