I have some data in the database, in this format:
Description~Level||Description~Level||
I want to transform this into an array where description is the Key & Level the value of the array.
$perso1 = explode('||', $myLevels['perso']);
$perso = array_slice($perso1, 0 , -1);
so far ive done this and it return that :
Array ( [0] => ffghtr~54644
[1] => ffghtr~54644
[2] => ffghtr~54644
[3] => ffghtr~54644
[4] => ffghtr~54644
[5] => ffghtr~54644 )
Now I cannot find a way to replace the array keys (0,1,2,etc) by my description.
Any idea ?
Thanks very much in advance.
Please note that in the posted example you always have the same key: “ffghtr”.
Because array keys are unique, you will end up replacing the content of this key with every iteration, having only the last element as the result.