11

Im sure this is something obvious i'm missing but I have a string 'GB' that is stored as $str and is then echoed out using strtolower...

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

I am expecting to see 'gb' (lowercase) but the output is still 'GB' (uppercase)

What could I be doing wrong?

UPDATE Turns out That the issue lied with bp_member_profile_data, this is a BuddyPress PHP function that automatically echos so it was ignoring the strtolower - Thanks to everybody for helping to narrow it down!

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
fightstarr20
  • 11,682
  • 40
  • 154
  • 278

2 Answers2

14

Try to use:

mb_strtolower($str);

This may work.

From PHP Manual:

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

The function prototype is:

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

You could try adding the appropriate encoding.

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

Jean
  • 7,623
  • 6
  • 43
  • 58
4

Check out buddy press bp_member_profile_data() function, 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()

enapupe
  • 15,691
  • 3
  • 29
  • 45