$string = $a[1][$row]; if (preg_match('/\"$/i', $string)) { echo "example <br>"; }else{ echo $string."<br>"; }