fork download
  1. <?php
  2.  
  3. function strtolowertr($metin){
  4. return mb_convert_case(str_replace('I','ı',$metin), MB_CASE_LOWER, "UTF-8");
  5. }
  6. function strtouppertr($metin){
  7. return mb_convert_case(str_replace('i','İ',$metin), MB_CASE_UPPER, "UTF-8");
  8. }
  9. function ucfirsttr($metin) {
  10. $metin = in_array(crc32($metin[0]),array(1309403428, -797999993, 957143474)) ? array(strtouppertr(substr($metin,0,2)),substr($metin,2)) : array(strtouppertr($metin[0]),substr($metin,1));
  11. return $metin[0].$metin[1];
  12. }
  13.  
  14. $s = "this is the, sample text.for replace the each words in, this'text sample' words";
  15. echo preg_replace_callback('~\b\w+~u', function ($m) { return ucfirsttr($m[0]); }, $s);
  16.  
Success #stdin #stdout 0.04s 52480KB
stdin
Standard input is empty
stdout
This İs The, Sample Text.For Replace The Each Words İn, This'Text Sample' Words