將一個數(shù)組中的所有奇數(shù)鍵值作為新KEY,將偶數(shù)鍵的值作為值.
例:
這就是當前設置的方式:
Array(? [0] => greeting? [1] => hello? [2] => question? [3] => how-are-you? [4] => response? [5] => im-fine)
這是它需要的(轉換后):
Array(? [greeting] => hello? [question] => how-are-you? [response] => im-fine)
方法
$result=array();
while(count($urls)) {
list($key,$value) = array_splice($urls,0,2);
$result[$key] =$value;
}
這將從URL列表中提取前兩個條目,并將其用作結果數(shù)組的鍵和值.重復,直到源列表為空.