Kathir SRS
Kathir SRS

Reputation: 37

Remove array keys from without removing the key values

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

Answers (3)

alwaysLearn
alwaysLearn

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

Praveen kalal
Praveen kalal

Reputation: 2129

please use this function

$arr = array_values($arr);

Upvotes: 0

user142162
user142162

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

Related Questions