php - Combine array form set of values and keys -
Hello everyone using php!
I am looking for an answer I have two arrays - the other array of indexes from individuals and person array.
person (array) selected index (array) [0] = & gt; 'Mark' [0] = & gt; 0 [1] = & gt; 'Jane' [1] = & gt; 2 [2] = & gt; 'Bob' [2] = & gt; 1 [3] = & gt; 'Jack' I want to create a third array which contains elements from the person array which is set in the selected indexes array Are there. As in SELECT * FROM, WHERE is the 'selected indexx' in the 'Person ID' but in PHP if you know what I am saying? I later use "forward" elements for the new array, but there is a small php solution eg inline?
Edit: Oh, and output should be:
selected person (array) [0] = & gt; 'Mark' [1] = & gt; 'Jane' [2] = & gt; 'Bob' (0, 2 and 1 only)
$ result = Array_intersect_key ($ people, array_flip ($ selected));
Comments
Post a Comment