php: write an array by clone -


I found this array;

  $ arr1 = array ("1", "2", "3", "4"); $ Arr2 = array ("a", "b", "c", "d"); $ X = array (1,3,4,2,4,1,2,2,3,4,4,4,1);  

I want to print $ x like this on the screen:

a, c, d, b, d, a, b, b, c, d , D, d, a

When you use a foreach loop Primitive Oh (I'm joking, I do not hate!), You can instead use the works designed for such things.

  $ map = array_combine ($ arr1, $ arr2); $ Result = array_map (use function ($ i) ($ map) {return $ map [$ i];}, $ x); Echo echo (",", $ result);  

Documentation: ,,,,
As a general rule, the use of built-in tasks will often be faster than speeding yourself.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -