0

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?

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

Comments

0

please use this function

$arr = array_values($arr);

Comments

0

You can use array_value() for your purpose.

$arr           = array("1"=>2,"2"=>5,"3"=>10);
$array_values  = array_values($arr);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.