Sunday, June 26, 2011

Get String in JavaScript - (Like strstr in php)

you want to find first occurrence of a string  in javascript, like strstr() function in php..? this the sample function code  to do this in javascript



in PHP


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

$user = strstr($email, '@', true);
echo $user; // prints name
?>

in Java Script







1 comment:

Anonymous said...

Well, your writing style is different as compare to others. You clear your point in a very well way. I’ll check your site regularly.
joomla extensions