I have this array
$arr = array('test1', 'test', 'test3', 'var1', 'var5', 'var');
and I want to trim/sort the array to be like this
$arr = array('test', 'var');
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.
This question is a little vague; it sounds to me like you’re asking how to filter out the elements that do not contain a digit, and the provided
$arris just an example. In which case you can do the following:This will also work if your array changes. If you need to sort the results alphabetically, then:
I could be wrong though; in which case this is slightly overkill.