title: if else condition not working with array values in php
body: <p>i have come to this strange issue.</p>
  
  <p>i am getting values from array and trying to compare it but its not working.</p>
  
  <p>Code-1</p>
  
  <pre><code>&lt;?php
  echo $data-&gt;item[0]['promocode'].'&lt;br&gt;';
  echo $data-&gt;item[1]['promocode']; 
  ?&gt;
  </code></pre>
  
  <p>Output-1</p>
  
  <pre><code>inhouse
  inhouse 
  </code></pre>
  
  <hr>
  
  <p>Now lets try with if else condition if both values are same or not
  Code-2</p>
  
  <pre><code>&lt;?php
  if(($data-&gt;item[0]['promocode']) == ($data-&gt;item[1]['promocode'])){
  echo "both values are same";
  } else {
  echo "both values are NOT same";
  }?&gt;
  </code></pre>
  
  <p>Output-2</p>
  
  <pre><code>both values are NOT same 
  </code></pre>
  
  <p><strong>Very strange</strong></p>
  
  <h2>i dont get it what i am doing wrong.</h2>
  
  <p>lets try above exaple with specifying variables
  Code-3</p>
  
  <pre><code>&lt;?php
  $data0=$data-&gt;item[0]['promocode'];
  $data1=$data-&gt;item[1]['promocode'];
  if($data0 == $data1){
  echo "both values are same";
  } else {
  echo "both values are NOT same";
  }?&gt;
  </code></pre>
  
  <p>Output-3</p>
  
  <pre><code>both values are NOT same 
  </code></pre>
  
  <p>I am pulling my hairs now.</p>
  
  <hr>
  
  <p>Now hard coding values in variables</p>
  
  <p>Code-4</p>
  
  <pre><code>&lt;?
  $data0='inhouse';
  $data1='inhouse';
  if($data0 == $data1){
  echo "both values are same";
  } else {
  echo "both values are NOT same";
  }?&gt;
  </code></pre>
  
  <p>Output-4</p>
  
  <pre><code>both values are same 
  </code></pre>
  
  <hr>
  
  <p>So my question is why is this happening ?</p>
  
  <p>i have array of elements and i wanna check previous value with the current value if try then do something.</p>
  
  <p>thanks for your time.</p>