Simple strtolower not working

I am sure this is something obvious, I went missing, but I have the string "GB" which is stored as $ str and then called with strtolower ...

$str = bp_member_profile_data('field=Country'); echo strtolower($str); 

I expect to see "gb" (lowercase), but the output is still "GB" (uppercase)

What can i do wrong?

UPDATE It turns out that the problem is related to bp_member_profile_data, it is a PHP BuddyPress function that automatically echoes, so it ignores strtolower - Thanks to everyone who helps narrow it down!

+8
php
source share
2 answers

Check the buddy function bp_member_profile_data() , it echoes:

 function bp_member_profile_data( $args = '' ) { echo bp_get_member_profile_data( $args ); } 

You might want to use bp_get_member_profile_data()

+4
source share

Try using:

 mb_strtolower($str); 

It might work.

From PHP Manual :

If the input string is in another language, then the server locale, then you should use the mb_strtolower () function.

Function Prototype:

 string mb_strtolower ( string $str [, string $encoding = mb_internal_encoding() ] ) 

You can try adding the appropriate encoding.

An encoding parameter is a character encoding. If omitted, the internal character encoding value will be used.

+4
source share

All Articles