Home » » strstr

strstr

Written By 1 on Sunday, September 30, 2012 | 9:56 AM

string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )

Find the first occurrence of a string

Returns part of haystack string starting from and including the first occurrence of needle to the end of haystack.


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

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

5.3.0 Added the optional parameter before_needle. 4.3.0 strstr() was made binary safe.


15.-Curso PHP-MySQL. Buscar y reemplazar substrings

0 Comment:

Post a Comment