jimfog Posted May 15, 2015 Share Posted May 15, 2015 I have these 2 arrays: array(5) { [0]=>string(6) "sunday"[1]=> string(6) "monday" [2]=>string(7) "tuesday"[3]=>string(6) "friday"[4]=> string(8) "saturday"}$hidd_days=[0=>'sunday',1=>'monday',2=>'tuesday',3=>'wednesday',4=>'thursday',5=>'friday',6=>'saturday']; I want somehow to merge these two arrays but in the following manner: In this 3rd array there will only be the weekdays mentioned in the first array but their keys will be the one corresponding in the second array...such as this: $third_array=[0=>'sunday',1=>'monday',2=>tuesday,5=>friday,6=>'saturday']; Link to comment Share on other sites More sharing options...
justsomeguy Posted May 15, 2015 Share Posted May 15, 2015 Loop through the first one and use array_search to check for the key in the second one. 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