I have a simple array like the following:
array
0 => string '101'
1 => string '105'
2 => string '103'
Desired result:
array(101, 105, 103)
Is this possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, use
array_values.Edit: (Thanks to @MarkBaker)
If you use
var_dumpon the original array and the “values only” array the output might look exactly the same if the keys are numerical and and ascending beginning from 0. Just like in your example.If the keys are not consisting of numbers or if the numbers are “random” then the output would be different. For example if the array looks like
the output of
var_dumplooks different after converting the array witharray_values.