There is a code:

$a[0]=preg_replace('/Для(\s)/u','для$1',$a[0]); $a[0]=preg_replace('/И(\s)/u','и$1',$a[0]); $a[0]=preg_replace('/Или(\s)/u','или$1',$a[0]); $a[0]=preg_replace('/На(\s)/u','на$1',$a[0]); 

The essence of this code is that it inserts the first letter in lower case in the line of text between the interjections. The line is such that all words in it begin with a capital letter.

To write something like this, but this is wrong:

 $a[0]=preg_replace('/(На|Для|Или|И)(\s)/u','DownCase($1)$2',$a[0]); 

I break my head ..

  • one
    Why regulars, why not: echo str_replace (array ('For', 'Or', 'And', 'On'), array ('for', 'or', 'and', 'to'), ' For Or And On '); - KiTE
  • well, yes .. is also an excellent option, it will even work faster, but the repetition of interjections is ugly, and it would also be a plus - jkeks
  • In this variant the error crept in. If, for example, the word Nalchik or Chief is, then his register is also lowered, and so is not necessary =) - jkeks
  • well, in fact, it is simply solved by adding a space in the string :) - Alex Kapustin
  • Yes, in most cases, interjections are somewhere in front of the space, but with regulars it is possible both at the end of the line and before the sign and question and even a point and even a comma .. - jkeks

1 answer 1

 $a[0] = preg_replace("/(На|Для|Или|И)(\s)/ue",'mb_strtolower("$1", "UTF-8")."$2"', $a[0]);' 

is it

  • Here is a mixture of quotes you need ... Thank you! - jkeks