[ create a new paste ] login | about

Link: http://codepad.org/28qYgol0    [ raw code | output | fork ]

PHP, pasted on Oct 30:
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);
?>


Output:
1
2
3
4
5
6
7
8
array(3) {
  [1]=>
  string(5) "value"
  [2]=>
  string(12) "anotherValue"
  [3]=>
  string(10) "thirdValue"
}


Create a new paste based on this one


Comments: