I want to increment an associative array keys in php?

Shereef H

New member
Array ( [0] => H [1] => e [2] => l [3] => l [4] => o )

& i want it to be :

Array ( [3] => H [4] => e [5] => l [6] => l [7] => o )
i tried everything but is not working plz answer me??
 
<?php
// treat this string as an array
$str = 'Hello';
// the result array
$arr = array();

// incrementor
$i = 3;
$j = 0;

// loop
for ($i, $j; $j < strlen($str); $i++, $j++)
{
$arr[$i] = $str[$j];
}

// show result
echo '<pre>';
print_r($arr);
?>

.hth
 
Back
Top