我有這個關聯數組,其中key2
和key5
始終與key1
具有相同的值。是否可以通過引用數組本身或任何其他建議來刪除值重複來設置它們的值?數組是否可以引用自己
$arr = array(
'key1' => 'some value',
'key2' => 'some value', //same as key1 and will always stay as key1
'key3' => 'some other value',
'key4' => 'yet another',
'key5' => 'some value' //same as key1 and will always stay as key1
);
如果他們永遠是一樣的,爲什麼你需要它在那裏的3倍? – barfoon 2011-06-06 03:00:59
@barfoon,因爲我通過鍵檢查數組。即使內部我的腳本將其視爲'$ arr ['key1']',我仍需要'$ arr ['key3']'。 – switch 2011-06-06 03:21:14