Page 2 of 2

Re: Forcing sentence start with Capital letter

Posted: Sun Jun 29, 2008 6:13 am
by koyauni
I put that ON an sill have problem. But the scrip works for domain without php.ini, I am not so sure what is in php.ini which stop it to work.

Re: Forcing sentence start with Capital letter

Posted: Mon Jun 30, 2008 12:00 am
by Stryks
Firstly, I think you should read and try to understand the suggestions that are offered when you ask a question. The suggestions were not 'drop-in' solutions, but answered your question had you given them a bit of a test. As it is, the solution you found was handed to you earlier on in the thread.

As it happens, I think that a slight modification of the code from JCart is still your best option.

You get your code to a string with punctuation and no capitalization, and you store it in the variable $data. Then ...

Code: Select all

$data = ucfirst(preg_replace_callback('/\A[a-z]|[.?!]\s*([a-z])/i', create_function('$matches', 'return strtoupper($matches[0]);'), $data));


... should do everything for you, including sentences ending in ? or !, regardless of the number of spaces or carriage returns used. This should also take care of paragraphs.

Next, I don't really understand what you are saying your problem is with this error, but did you know that you have used the same variable in two different ways on your example?

Try using ...

Code: Select all

$_POST["ArabicText"]
... in all places where you need to access this value, instead of ...

Code: Select all

$_POST[ArabicText]
Let me know if this helps.