Detect capitalization of a string and apply it to another string in PHP -


As a title, suggests that I am trying to figure out the capitalization of a string and apply the same formatting on the same string.

Example:
Yellow Paneer & gt; & Gt; & Gt; It detects that this is only the first character of the capitals & gt; & Gt; & Gt;

You can try:

 

$ Ref = 'yellow cheese'; $ Str = 'blue cheese'; $ Ref_words = explosion ('', $ ref); $ Str_words = explosion ('', $ str); $ I + 0; $ i & Lt; count ($ ref_words); $ i ++) {if (preg_match ('/ ^ [AZ] /', $ ref_words [$ i])) {$ str_words [$ i] = ucfirst ($ str_words [$ i ];}} $ Res = implode ('', $ str_words); $ Res echo, "\ n";

Output:

  Blue cheese    

Comments