Rumah >pembangunan bahagian belakang >tutorial php >php关于数组的有关问题
php关于数组的问题
<br />array (size=3)<br /> 0 => <br /> array (size=3)<br /> 0 => <br /> array (size=3)<br /> 'welfareName' => string '包吃住' (length=9)<br /> 'welfareIco' => string 'url_1' (length=5)<br /> 'xyId' => int 1<br /> 1 => <br /> array (size=3)<br /> 'welfareName' => string '头等舱' (length=9)<br /> 'welfareIco' => string 'url_2' (length=5)<br /> 'xyId' => int 1<br /> 2 => <br /> array (size=3)<br /> 'welfareName' => string '有车' (length=6)<br /> 'welfareIco' => string 'url_4' (length=5)<br /> 'xyId' => int 1<br /> 1 => <br /> array (size=2)<br /> 0 => <br /> array (size=3)<br /> 'welfareName' => string '头等舱' (length=9)<br /> 'welfareIco' => string 'url_2' (length=5)<br /> 'xyId' => int 2<br /> 1 => <br /> array (size=3)<br /> 'welfareName' => string '买买买' (length=9)<br /> 'welfareIco' => string 'url_3' (length=5)<br /> 'xyId' => int 2<br /> <br />---------------------------------------------------------<br />array (size=3)<br /> 0 => <br /> array (size=11)<br /> 'xyId' => int 1<br /> 'xyLocation' => string '首尔' (length=6)<br /> 'commentNum' => int 3<br /> 'visitorNum' => int 1<br /> 1 => <br /> array (size=11)<br /> 'xyId' => int 2<br /> 'xyLocation' => string '东京' (length=6)<br /> 'commentNum' => int 0<br /> 'visitorNum' => int 1<br />--------------------------------------------------------------------------------<br />array (size=3)<br /> 0 => <br /> array (size=11)<br /> 'xyId' => int 1<br /> 'xyLocation' => string '首尔' (length=6)<br /> 'commentNum' => int 3<br /> 'visitorNum' => int 1<br /> 'welfare' =><br /> array (size=3)<br /> 0 => <br /> array (size=3)<br /> 'welfareName' => string '包吃住' (length=9)<br /> 'welfareIco' => string 'url_1' (length=5)<br /> 'xyId' => int 1<br /> 1 => <br /> array (size=3)<br /> 'welfareName' => string '头等舱' (length=9)<br /> 'welfareIco' => string 'url_2' (length=5)<br /> 'xyId' => int 1<br /> 2 => <br /> array (size=3)<br /> 'welfareName' => string '有车' (length=6)<br /> 'welfareIco' => string 'url_4' (length=5)<br /> 'xyId' => int 1<br /> <br /> 1 => <br /> array (size=11)<br /> 'xyId' => int 2<br /> 'xyLocation' => string '东京' (length=6)<br /> 'commentNum' => int 0<br /> 'visitorNum' => int 1<br /> 'welfare' => <br /> array (size=2)<br /> 0 => <br /> array (size=3)<br /> 'welfareName' => string '头等舱' (length=9)<br /> 'welfareIco' => string 'url_2' (length=5)<br /> 'xyId' => int 2<br /> 1 => <br /> array (size=3)<br /> 'welfareName' => string '买买买' (length=9)<br /> 'welfareIco' => string 'url_3' (length=5)<br /> 'xyId' => int 2<br />
for($i=0; $i<count($数组2); $i++) {<br /> $数组3[$i] = $数组2;<br /> $数组3[$i]['welfare'] = @$数组1[$i];<br />}
<br />$arr1=array(<br /> array (<br /> array (<br /> 'welfareName' => '包吃住',<br /> 'welfareIco' => 'url_1',<br /> 'xyId' => 1<br /> ),<br /> array (<br /> 'welfareName' => '头等舱',<br /> 'welfareIco' => 'url_2',<br /> 'xyId' =>1<br /> ),<br /> array (<br /> 'welfareName' =>'有车',<br /> 'welfareIco' => 'url_4',<br /> 'xyId' =>1<br /> )<br /> ),<br /> array (<br /> array (<br /> 'welfareName' => '头等舱',<br /> 'welfareIco' => 'url_2',<br /> 'xyId' =>2<br /> ),<br /> array (<br /> 'welfareName' => '买买买',<br /> 'welfareIco' => 'url_3',<br /> 'xyId' =>2<br /> )<br /> )<br />);<br />$arr2=array(<br /> array (<br /> 'xyId' => 1,<br /> 'xyLocation' => '首尔',<br /> 'commentNum' =>3,<br /> 'visitorNum' =>1,<br /> ),<br /> array (<br /> 'xyId' => 2,<br /> 'xyLocation' => '东京',<br /> 'commentNum' => 0,<br /> 'visitorNum' => 1,<br /> )<br />);<br />foreach($arr1 as $k=>$v){<br /> $new[$v[0]['xyId']]=$v;<br />}<br />foreach($arr2 as $k=>$v){<br /> $arr2[$k]['welfare']=$new[$v['xyId']];<br />}<br />