Wednesday, June 25, 2008

PHP String Funcitons

$txt="PHP MYSQL";
echo $txt; // Returns PHP MYSQL (Print the text)

echo strlen("My first coding in PHP"); // Returns 22 (Print the string length)

echo strpos("Hello world","l"); // Returns 2 (Print the string position)

$email = 'ashokseenivas50@gmail.com';
$domain = strstr($email, '@');
echo $domain; // prints @gmail.com

$user = strstr($email, '@', true);
echo $user; // prints ashokseenivas50

No comments: