Reputation: 37
Can any one please tell me how to remove the array key from array without removing the key value. For example:
This is my value:
$arr = array("1"=>2,"2"=>5,"3"=>10);
What I want is:
$arr = array(2,5,10);
If both equal how the default keys are assigned?
Upvotes: 0
Views: 104
Reputation: 6950
You can use array_value() for your purpose.
$arr = array("1"=>2,"2"=>5,"3"=>10);
$array_values = array_values($arr);
Upvotes: 0
Reputation:
Use the array_values
function:
$arr = array_values($arr);
From the documentation:
array_values()
returns all the values from the input array and indexes the array numerically.
Upvotes: 4