string(3) "1:6" [2]=> string(3) "2"/> string(3) "1:6" [2]=> string(3) "2">
Heim >Backend-Entwicklung >PHP-Tutorial >请问一个数据格式转换
请教一个数据格式转换
<br />array(5) {<br /> [0]=><br /> string(3) "0:3"<br /> [1]=><br /> string(3) "1:6"<br /> [2]=><br /> string(3) "2:9"<br /> [3]=><br /> string(3) "3:2"<br /> [4]=><br /> string(3) "4:4"<br />}<br />
<br />array(5) {<br /> 0=>3,<br /> 1=>6,<br /> 2=>9,<br /> 3=>2,<br /> 4=>4<br />}<br /><br />
$ar = array('0:3', '1:6', '2:9', '3:2', '4:4');<br /><br />foreach($ar as $v) {<br /> $t = explode(':', $v);<br /> $res[$t[0]] = $t[1];<br />}<br /><br />print_r($res);Array