I have copied some item manually from web pasted into txt and then stored it into database.Now what I missed is invisible characters.
when I'm retrieving first characters of each word using different values in substr($word,0,x) it shows presence of invisible characters.
php code-
public function getPrefixAttribute()
{
$str=$this->attributes['Subject_name'];
$exclude=array('And', 'of','in');
$ret = '';
foreach (explode(' ', $str) as $word)
{
if(in_array($word, $exclude))
{continue;}
else{
$ret .= strtoupper(substr($word,0,1));}
}
return $ret;
}
output-
substr($word,0,1)
string-'data structures and algorithms'
output-'SA'
expected-'DSA'
string-'Web Development'
output-'WD'
substr($word,0,2)
string-'data structures and algorithms'
output-'DSTAL'
expected-'DASTAL'
string-'Web Development'
output-'WEDE'