PHP Ferrari
PHP Ferrari

Reputation: 15616

Third argument in strstr is only valid in PHP 5.3.0

Hello I want to get user from an email address,

eg: [email protected] then output must be sajid

for this i use below mentioned code

$user = strstr($email, '@', true);

but an warning occur

Warning: Wrong parameter count for strstr() in /var/www/DataTable/dialog.php on line 3

& in php manul it is clearly define that the 3rd argument true is only valid for PHP 5.3.0

So is there any string function which could solve my problem?

Upvotes: 1

Views: 348

Answers (3)

Your Common Sense
Your Common Sense

Reputation: 157860

$name=strtok($email,"@");

Upvotes: 2

Pekka
Pekka

Reputation: 449405

Look in the User Generated Comments on the manual page, there are a few implementations.

Upvotes: 1

Michael Mrozek
Michael Mrozek

Reputation: 175365

$user = substr($email, 0, strpos($email, '@'));

Upvotes: 3

Related Questions