title: Remove values from array if not in other array, but keeping same order
body: <p>I have two arrays:</p>
  
  <p>$array1:</p>
  
  <pre><code>Array
  (
      [0] =&gt; 2032
      [1] =&gt; 2027
      [2] =&gt; 2025
      [3] =&gt; 2023
      [4] =&gt; 2021
      [5] =&gt; 2018
      [6] =&gt; 2014
      [7] =&gt; 2011
      [8] =&gt; 2009
      [9] =&gt; 1947
      [10] =&gt; 1941
      [11] =&gt; 1939
      [12] =&gt; 1937
      [13] =&gt; 1935
      [14] =&gt; 1933
      [15] =&gt; 1928
      [16] =&gt; 1926
      [17] =&gt; 1924
      [18] =&gt; 1922
      [19] =&gt; 1920
      [20] =&gt; 1918
      [21] =&gt; 1916
      [22] =&gt; 1910
      [23] =&gt; 1881
      [24] =&gt; 1680
      [25] =&gt; 1678
      [26] =&gt; 1879
      [27] =&gt; 1877
      [28] =&gt; 1875
      [29] =&gt; 1873
      [30] =&gt; 1871
      [31] =&gt; 1869
      [32] =&gt; 1865
      [33] =&gt; 1863
      [34] =&gt; 1858
      [35] =&gt; 1850
      [36] =&gt; 1844
      [37] =&gt; 1838
      [38] =&gt; 1829
      [39] =&gt; 1827
      [40] =&gt; 1825
      [41] =&gt; 1821
      [42] =&gt; 1819
      [43] =&gt; 1814
      [44] =&gt; 1812
      [45] =&gt; 1810
      [46] =&gt; 1808
      [47] =&gt; 1806
      [48] =&gt; 1804
      [49] =&gt; 1801
      [50] =&gt; 1793
      [51] =&gt; 1791
      [52] =&gt; 1789
      [53] =&gt; 1784
      [54] =&gt; 1774
      [55] =&gt; 1772
      [56] =&gt; 1770
      [57] =&gt; 1768
      [58] =&gt; 1766
      [59] =&gt; 1764
      [60] =&gt; 1762
      [61] =&gt; 1760
      [62] =&gt; 1754
      [63] =&gt; 1748
      [64] =&gt; 1746
      [65] =&gt; 1744
      [66] =&gt; 1740
      [67] =&gt; 1738
      [68] =&gt; 1732
      [69] =&gt; 1722
      [70] =&gt; 1720
      [71] =&gt; 1716
      [72] =&gt; 1714
      [73] =&gt; 1711
      [74] =&gt; 1708
      [75] =&gt; 1703
      [76] =&gt; 1699
      [77] =&gt; 1673
      [78] =&gt; 1671
      [79] =&gt; 1669
      [80] =&gt; 1667
      [81] =&gt; 1665
      [82] =&gt; 1663
      [83] =&gt; 1661
      [84] =&gt; 1659
      [85] =&gt; 1655
  )
  </code></pre>
  
  <p>$array2:</p>
  
  <pre><code>Array
  (
      [0] =&gt; 1665
      [1] =&gt; 1671
      [2] =&gt; 1714
      [3] =&gt; 1716
      [4] =&gt; 1722
      [5] =&gt; 1732
      [6] =&gt; 1774
      [7] =&gt; 1801
      [8] =&gt; 1804
      [9] =&gt; 1916
      [10] =&gt; 1918
      [11] =&gt; 1920
      [12] =&gt; 1924
      [13] =&gt; 1933
      [14] =&gt; 1935
      [15] =&gt; 1939
  )
  </code></pre>
  
  <p>What I need to do is check each value of array one and see if it is in array two, if the value is in array two then place that value into array three. But array three needs to stay in the order that the values appear in array one.</p>
  
  <p>I can just write some code to loop through array one do an in_array() and if true drop into array three. This would work but the reason for my question is that is there any function already available for this task? If not then whats the most effiecient and speedy way to do this?</p>