php关于数组的有关问题

WBOY
Freigeben: 2016-06-13 12:20:26
Original
1206 Leute haben es durchsucht

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 />
Nach dem Login kopieren

------解决思路----------------------
for($i=0; $i<count($数组2); $i++) {<br />  $数组3[$i] = $数组2;<br />  $数组3[$i]['welfare'] = @$数组1[$i];<br />}
Nach dem Login kopieren

------解决思路----------------------
<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 />
Nach dem Login kopieren

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!