Response to arif:
We do not need that long functions. In order to make ucwords() worked properly in Turkish words that contain speacial characters, we can use the following command in our php codes:
setlocale(LC_ALL, 'tr_TR');
This will set locale to Turkish.