title: How to check if two variable in php are same or not?
body: <p>I want to compare date with database ? so I preg all special character from the date. but some how it always return true  if both vale are not same. What I am doing wrong please help.</p>
  
  <pre><code>//input value
  $user_dob       = $_POST['user_dob'];
  $preg_input_dob  = preg_replace("/[^a-zA-Z0-9\s]/", "",$user_dob); //output 18101984
  
  
  
  //db value 
  $date_of_birth = $user_info-&gt;date_of_birth;
  $preg_db_dob  = preg_replace("/[^a-zA-Z0-9\s]/", "", $date_of_birth); //output 18101984
  
  
  if($preg_input_dob != $preg_db_dob ){
      echo "Date of birth mismatch";
  }else{
      echo "Your date of birth is correct";
  }
  </code></pre>