1 2 3 4 5 6 7 8 9 10 11 12
<?php $myString = "value,anotherValue,thirdValue"; $someArray = explode(",",$myString); $tempArray = array(); foreach($someArray as $key=>$value) { $tempArray[$key+1] = $value; } $someArray = $tempArray; var_dump($someArray); ?>
1 2 3 4 5 6 7 8
array(3) { [1]=> string(5) "value" [2]=> string(12) "anotherValue" [3]=> string(10) "thirdValue" }