Tuesday, September 2, 2008

strstr() and stristr() in php

What is the functionality of the function strstr and stristr?
- strstr -- Find first occurrence of a string
- Example :
$email = 'user@example.com';
$domain = strstr($email, '@');
echo $domain; // prints @example.com
?>
- stristr -- Case-insensitive strstr()
- Example :
$email = 'USER@EXAMPLE.com';
$domain = stristr($email, 'e');
echo $domain;
// outputs ER@EXAMPLE.com
?>

What is meant by nl2br()?
- nl2br -- Inserts HTML line breaks before all newlines in a string
- Example :
echo nl2br("foo isn't\n bar");
/*output :
foo isn't

bar
*/
?>

No comments:

Popular Posts