先做个问题记录,另外下面是做的过程中遇到的一个没想明白的现象
foreach($result as $key => $val ){
$wzList[$key]['lik']=$val[0];
$wzList[$key]["likN"]=$val[1];
}
用这种方法生成的数组是这样的:
array(9) { [0] => array(2) { ["lik"] => string(45) "coll_fa4c5d7a78118c73a9a6c2421ae3e40a.html" ["likN"] => string(60) "如果女同事偷偷拿它射你,蜜汁尴尬了。。。" } [1] => array(2) { ["lik"] => string(42) "coll_fa4c5d7a78118c73a9a6c2421ae3e40a.html" ["likN"] => string(60) "如果女同事偷偷拿它射你,蜜汁尴尬了。。。" } [2] => array(2) { ["lik"] => string(42) "coll_fba8ebd181d6b7526f7b2aa50a366a44.html" ["likN"] => string(72) "好消息!!广州汽车客运站已经开始售春节回家的票了" } [3] => array(2) { ["lik"] => string(42) "coll_e988992a2881ab957e8f3e19bbfc2da8.html" ["likN"] => string(45) "看了之后,你还敢去超市买菜吗?" } [4] => array(2) { ["lik"] => string(42) "coll_e988992a2881ab957e8f3e19bbfc2da8.html" ["likN"] => string(45) "看了之后,你还敢去超市买菜吗?" } [5] => array(2) { ["lik"] => string(42) "coll_e988992a2881ab957e8f3e19bbfc2da8.html" ["likN"] => string(45) "看了之后,你还敢去超市买菜吗?" } [6] => array(2) { ["lik"] => string(42) "coll_6bf7e13f69e5a362fc3065db2f4c1b0f.html" ["likN"] => string(66) "原始生态小洲村,带你走入繁华城市中的一片净土" } [7] => array(2) { ["lik"] => string(42) "coll_6bf7e13f69e5a362fc3065db2f4c1b0f.html" ["likN"] => string(66) "原始生态小洲村,带你走入繁华城市中的一片净土" } [8] => array(2) { ["lik"] => string(42) "coll_0896ab80d68a7d0806f51d3b3324ca5a.html" ["likN"] => string(44) "帮我做个APP,给你20万,做不做?" } }
foreach($result as $key => $val ){
$wzList[]['lik']=$val[0];
$wzList[]["likN"]=$val[1];
}
用这个方法生成的二维数组却是这样的:
array(18) { [0] => array(1) { ["lik"] => string(45) "coll_fa4c5d7a78118c73a9a6c2421ae3e40a.html" } [1] => array(1) { ["likN"] => string(60) "如果女同事偷偷拿它射你,蜜汁尴尬了。。。" } [2] => array(1) { ["lik"] => string(42) "coll_fa4c5d7a78118c73a9a6c2421ae3e40a.html" } [3] => array(1) { ["likN"] => string(60) "如果女同事偷偷拿它射你,蜜汁尴尬了。。。" } [4] => array(1) { ["lik"] => string(42) "coll_fba8ebd181d6b7526f7b2aa50a366a44.html" } [5] => array(1) { ["likN"] => string(72) "好消息!!广州汽车客运站已经开始售春节回家的票了" } [6] => array(1) { ["lik"] => string(42) "coll_e988992a2881ab957e8f3e19bbfc2da8.html" } [7] => array(1) { ["likN"] => string(45) "看了之后,你还敢去超市买菜吗?" } [8] => array(1) { ["lik"] => string(42) "coll_e988992a2881ab957e8f3e19bbfc2da8.html" } [9] => array(1) { ["likN"] => string(45) "看了之后,你还敢去超市买菜吗?" } [10] => array(1) { ["lik"] => string(42) "coll_e988992a2881ab957e8f3e19bbfc2da8.html" } [11] => array(1) { ["likN"] => string(45) "看了之后,你还敢去超市买菜吗?" } [12] => array(1) { ["lik"] => string(42) "coll_6bf7e13f69e5a362fc3065db2f4c1b0f.html" } [13] => array(1) { ["likN"] => string(66) "原始生态小洲村,带你走入繁华城市中的一片净土" } [14] => array(1) { ["lik"] => string(42) "coll_6bf7e13f69e5a362fc3065db2f4c1b0f.html" } [15] => array(1) { ["likN"] => string(66) "原始生态小洲村,带你走入繁华城市中的一片净土" } [16] => array(1) { ["lik"] => string(42) "coll_0896ab80d68a7d0806f51d3b3324ca5a.html" } [17] => array(1) { ["likN"] => string(44) "帮我做个APP,给你20万,做不做?" } }
基础太差了,想了好久没想清楚这两者的区别,求高手指教....