-2

How can i change an index of an array in php? for example

$myArray = {"x","y","z","w"};

I want to change the index of myArray [2] to myArray ["two"]

levenzer
  • 3
  • 1

1 Answers1

0

You could use unset() to achieve this:

$myArray = ["x","y","z","w"];
$myArray['two'] = $myArray[2];
unset($myArray[2]);
Miroslav Glamuzina
  • 4,374
  • 2
  • 17
  • 33