help needed in ( strstr )

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

help needed in ( strstr )

Post by minos_mks »

i have a .dat file save on it the user name - the password like :

mina - 12345
mary - 54321
jaky saad - 987654

i need a function to get the user name in a variable and i used this script but it gives me that "wrong parameter count for strstr"

$buffer_line = trim($line);
$buffer_name = strstr($buffer_line, '-', true);

note: i found this exact function on php.net

thank you for your help
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

Re: help needed in ( strstr )

Post by Technocrat »

Are you running php 5.3.x? The before_needle was added in 5.3.0.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: help needed in ( strstr )

Post by AbraCadaver »

How about:

Code: Select all

list($name, $pass) = explode(' - ', trim($line));
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
minos_mks
Forum Commoner
Posts: 69
Joined: Thu Feb 04, 2010 1:58 am

Re: help needed in ( strstr )

Post by minos_mks »

thank you very much , god bless you
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: help needed in ( strstr )

Post by AbraCadaver »

You're welcome. But please pay attention to what Technocrat-Evo has said. When using PHP functions, look at the manual page and see what version the function is included in, as well as the notes as to how the function changed in specific versions.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply