army20 Posted August 16, 2006 Posted August 16, 2006 (edited) Hello All,I have a very simple PHP script and I would like to "extract" or print or echo only the first letter of my variable. Is this possible ?By exemple let's say my variable $_POST['profil'] return my first name, martin, I would like to have only the first letter so thaht would be the "m" in that case.Thanks-Martin Edited August 16, 2006 by army20
tain Posted August 16, 2006 Posted August 16, 2006 http://us2.php.net/manual/en/function.substr.php has two examples:echo substr('abcdef', 1); // bcdefecho substr('abcdef', 1, 3); // bcdecho substr('abcdef', 0, 4); // abcdecho substr('abcdef', 0, 8); // abcdefecho substr('abcdef', -1, 1); // fecho $string{0}; // aecho $string{3}; // decho $string{strlen($string)-1}; // f
army20 Posted August 16, 2006 Author Posted August 16, 2006 Do you have any idea how I may echo the same vaariable using all lower caseInput is : VaRIaBleOutput needed: variable
tain Posted August 16, 2006 Posted August 16, 2006 php.net is your friend. http://us3.php.net/manual/en/function.strtolower.php<?php$str = "Mary Had A Little Lamb and She LOVED It So";$str = strtolower($str);echo $str; // Prints mary had a little lamb and she loved it so?>
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now