jimfog Posted June 1, 2015 Share Posted June 1, 2015 I have an array like this one: $weekdays_all=['monday'=>NULL,'monday_b'=>NULL,'tuesday'=>NULL,'tuesday_b'=>NULL.etc]; I want to extract all the _b days from it and push them into a new array... $b_days=['monday_b'=>NULL,'tuesday_b'=>NULL]; How I am going to do it? Link to comment Share on other sites More sharing options...
davej Posted June 1, 2015 Share Posted June 1, 2015 Maybe... foreach ($weekdays_all as $key => $value) { if (strpos($key, '_b', strlen($key)-2) !== false) $b_days[$key] = $value; }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now