php 二维数组赋值定义
这个数组怎么定义?Array([0]=>Array([id]=>1[xuefei]=>50万以下)[1]=>Array([id]=>2[xuefei]=>51万~60万)...
这个数组怎么定义?
Array (
[0] => Array ( [id] => 1 [xuefei] => 50万以下 )
[1] => Array ( [id] => 2 [xuefei] =>51万~60万 )
[2] => Array ( [id] => 3 [xuefei] => 61万~70万 )
[3] => Array ( [id] => 4 [xuefei] => 71万~80万 )
[4] => Array ( [id] => 5 [xuefei] => 81万~90万 )
[5] => Array ( [id] => 6 [xuefei] => 90万以上) ) 展开
Array (
[0] => Array ( [id] => 1 [xuefei] => 50万以下 )
[1] => Array ( [id] => 2 [xuefei] =>51万~60万 )
[2] => Array ( [id] => 3 [xuefei] => 61万~70万 )
[3] => Array ( [id] => 4 [xuefei] => 71万~80万 )
[4] => Array ( [id] => 5 [xuefei] => 81万~90万 )
[5] => Array ( [id] => 6 [xuefei] => 90万以上) ) 展开
5个回答
2015-07-07
展开全部
多维数组定义、赋值参考如下:
<?php
$fruits = array ( "fruits" => array ( "a" => "orange",
"b" => "banana",
"c" => "apple"
),
"numbers" => array ( 1,
2,
3,
4,
5,
6
),
"holes" => array ( "first",
5 => "second",
"third"
)
);
// Some examples to address values in the array above
echo $fruits["holes"][5]; // prints "second"
echo $fruits["fruits"]["a"]; // prints "orange"
unset($fruits["holes"][0]); // remove "first"
// Create a new multi-dimensional array
$juices["apple"]["green"] = "good";
?>
<?php
$fruits = array ( "fruits" => array ( "a" => "orange",
"b" => "banana",
"c" => "apple"
),
"numbers" => array ( 1,
2,
3,
4,
5,
6
),
"holes" => array ( "first",
5 => "second",
"third"
)
);
// Some examples to address values in the array above
echo $fruits["holes"][5]; // prints "second"
echo $fruits["fruits"]["a"]; // prints "orange"
unset($fruits["holes"][0]); // remove "first"
// Create a new multi-dimensional array
$juices["apple"]["green"] = "good";
?>
展开全部
$arr = array(array('id'=>1, 'xuefei'=>"50万以下" ), array('id'=>2, 'xuefei'=>"51万~60万" ));
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$arr = array(
array('id'=>1,'xuefei'=>'50万以下'),
array('id'=>2,'xuefei'=>'51万~60万'),
array('id'=>3,'xuefei'=>'61万~70万'),
array('id'=>4,'xuefei'=>'71万~80万'),
array('id'=>5,'xuefei'=>'81万~90万'),
array('id'=>6,'xuefei'=>'90万以上'));
array('id'=>1,'xuefei'=>'50万以下'),
array('id'=>2,'xuefei'=>'51万~60万'),
array('id'=>3,'xuefei'=>'61万~70万'),
array('id'=>4,'xuefei'=>'71万~80万'),
array('id'=>5,'xuefei'=>'81万~90万'),
array('id'=>6,'xuefei'=>'90万以上'));
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$xuefei = array(array(id=>1,xuefei=>'50万以下'),array(id=>2,xuefei=>'50万~60万'),array(id=>3,xuefei=>'60万~70万'),array(id=>4,xuefei=>'70万~80万'),array(id=>5,xuefei=>'80万~90万'),array(id=>6,xuefei=>'90万以上'));
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
示例:
$array = array();
$item = array();
$item['id'] = 1;
$item['xuefei'] = '50w';
$array[] = $item;
这三行
$item = array();
$item['id'] = 1;
$item['xuefei'] = '50w';
等效于 $item = array('id' => 1, 'xuefei' => '50w');
在php中,对于数组可以直接使用$array[]的方法在其尾部追加一个元素。例如
$array = array();
$array[] = 1;
结果为
Array (
0 => 1
)
$array = array();
$item = array();
$item['id'] = 1;
$item['xuefei'] = '50w';
$array[] = $item;
这三行
$item = array();
$item['id'] = 1;
$item['xuefei'] = '50w';
等效于 $item = array('id' => 1, 'xuefei' => '50w');
在php中,对于数组可以直接使用$array[]的方法在其尾部追加一个元素。例如
$array = array();
$array[] = 1;
结果为
Array (
0 => 1
)
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |