Reputation: 2177
I have an array with string value in PHP for example : arr['apple'], arr['banana']
, and many more -about 20-30 data (get it from some process). Now I want to get its value and return it to one variable.
For example, I have Original array is like this:
$arr['Apple']
$arr['Banana']
and more..
and result that I want is like this:
$arr[0] = "Apple"
$arr[1] = "Banana"
and more..
Any idea how to do that?
Upvotes: 1
Views: 47
Reputation: 68526
Use array_flip()
$new_arr = array_flip($old_arr);
Upvotes: 1
Reputation: 5443
use array_keys
function:
$keys = array_keys($arr);
It returns an array of all the keys in array.
Upvotes: 0