vinpkl
September 30, 2012, 5:36am
1
hi
my select options are getting echo as upper case
<select>
<option><? echo strtoupper($row['category_name']); ?></option>
</select>
there are some option names that contain “&” sign. So I am replacing that sign with “&”
$row['category_name'] = str_replace("&", "&", $row['category_name']);
but this outputs “&” as uppercase “&” which gives error while validating the code
WALL & CAR CHARGER
how can i have “&” in lowercase and rest in uppercase
vineet
rpkamp
September 30, 2012, 8:55am
2
<select>
<option><? echo str_replace('&', '&', strtoupper($row['category_name'])); ?></option>
</select>
Although it would be better to replace & with & /AFTER/ you’ve converted the text to uppercase; escaping is always the last thing you should do, for exactly the reason you’re asking this question
So, better would be:
<select>
<option><? echo htmlentities(strtoupper($row['category_name']), ENT_COMPAT, 'UTF-8', false); ?></option>
</select>
and then remove the part where you replace & with &
vinpkl
September 30, 2012, 9:09am
3
rpkamp:
So, better would be:
<select>
<option><? echo htmlentities(strtoupper($row['category_name']), ENT_COMPAT, 'UTF-8', false); ?></option>
</select>
thanks scallio
this option is much better and works perfect
vineet