title: Match each index of multidimensional array in php
body: <p>I have an array like this</p>
  
  <pre><code>   $msg =  Array
  (
  
      [0] =&gt; stdClass Object
          (
              [id] =&gt; 638
              [user_id] =&gt; 358253
              [raw_text] =&gt; Your package with Philips QG3387 Multi Grooming Kit (Black) has been successfully delivered. Thank you for choosing us.
              [type_of_message] =&gt; ECOMMERCE
              [sub_type_of_message] =&gt; DELIVERY_STATUS
              [product_description] =&gt; Philips QG3387 Multi Grooming Kit (Black)
  
          )
  
      [1] =&gt; stdClass Object
          (
              [id] =&gt; 641
              [user_id] =&gt; 358253
              [raw_text] =&gt; Your package with Philips QG3387 Multi Grooming Kit (Black) could not be delivered as addressee was not available. www.amazon.in/track
              [type_of_message] =&gt; ECOMMERCE
              [sub_type_of_message] =&gt; DELIVERY_STATUS
              [product_description] =&gt; Philips QG3387 Multi Grooming Kit (Black)
  
          )
  
  
  
      [2] =&gt; stdClass Object
          (
              [id] =&gt; 907
              [user_id] =&gt; 358253
              [raw_text] =&gt; Dispatched: Your package with Gadget Advice 720*480 Newest Smiley Face DVR Hidden S... will be delivered on or before 16-Jul. Track at http://amzn.in/5bIkuau
              [type_of_message] =&gt; ECOMMERCE
              [sub_type_of_message] =&gt; 
              [product_description] =&gt; Your package with Gadget Advice 720*480 Newest Smiley Face DVR Hidden S...
  
          )
  
      [3] =&gt; stdClass Object
          (
              [id] =&gt; 910
              [user_id] =&gt; 358253
              [raw_text] =&gt; Your order with order id 171-5257992-6082713 has been successfully placed. Please check email for more details. Thank you for shopping at Amazon.
              [type_of_message] =&gt; ECOMMERCE
              [sub_type_of_message] =&gt; 
              [product_description] =&gt; 
  
          )
  
      [4] =&gt; stdClass Object
          (
              [id] =&gt; 914
              [user_id] =&gt; 358253
              [raw_text] =&gt; Your order with order id 404-4813325-2653153 has been successfully placed. Please check email for more details. Thank you for shopping at Amazon.
              [type_of_message] =&gt; ECOMMERCE
              [sub_type_of_message] =&gt; 
              [product_description] =&gt; 
  
          )
  
      [5] =&gt; stdClass Object
          (
              [id] =&gt; 922
              [user_id] =&gt; 358253
              [raw_text] =&gt; Your package with Philips QG3387 Multi Grooming Kit (Black) has been successfully delivered. Thank you for choosing us.
              [type_of_message] =&gt; ECOMMERCE
              [sub_type_of_message] =&gt; DELIVERY_STATUS
              [product_description] =&gt; Philips QG3387 Multi Grooming Kit (Black)
  
          )
  
      [6] =&gt; stdClass Object
          (
              [id] =&gt; 925
              [user_id] =&gt; 358253
              [raw_text] =&gt; Your package with Philips QG3387 Multi Grooming Kit (Black) could not be delivered as addressee was not available. www.amazon.in/track
              [type_of_message] =&gt; ECOMMERCE
              [sub_type_of_message] =&gt; DELIVERY_STATUS
              [product_description] =&gt; Philips QG3387 Multi Grooming Kit (Black)
  
          )
  )
  </code></pre>
  
  <p>I want to compare $msg[0][product_description] with $msg[1][product_description] for each index and create a new array</p>
  
  <pre><code>if($msg[0][product_description] != $msg[1][product_description]) then $newArr[] = $msg[0][product_description]
  if($msg[0][product_description] == $msg[1][product_description]) then $newArr[] = $msg[1][product_description]
  if($msg[1][product_description] == $msg[2][product_description]) then $newArr[] = $msg[2][product_description]
  </code></pre>
  
  <p>I want to compare $msg[0][product_description] with other indexes if the value is same then move that index to new array. Same comparison with other indexes.
  Please help</p>