<?php $a = array("foo", "bar"); $aa = array(); foreach ($a as $idx => $val) { $aa[$val] = $idx + 1; } print_r($aa); ?>