Forum Moderators: coopster

Message Too Old, No Replies

Wrong parameter count for strstr()

         

carsten888

12:41 pm on Nov 20, 2007 (gmt 0)

10+ Year Member



I get the error:
Wrong parameter count for strstr()
for this code:

<?php

$text = 'safelogin.org<hr />no keylogging';
$text_before_needle = strstr($text, '<hr />', true);
$text_after_needle = strstr($text, '<hr />', false);

echo 'text_before_needle='.$text_before_needle.'<br />';
echo 'text_after_needle='.$text_after_needle.'<br />';

?>

of course I read:
[nl3.php.net...]
but I can't find whats wrong.

so I got a string (haystack), then want to get the string before the search-thing (needle), then want to get the string after the needle.

what am I overlooking?

barns101

1:13 pm on Nov 20, 2007 (gmt 0)

10+ Year Member



Your version of PHP probably doesn't support the third parameter (true/false). Remove that and check if it works.

carsten888

11:45 am on Nov 21, 2007 (gmt 0)

10+ Year Member



I'm using PHP5 on WAMP.
I removed the 3rd parameter and now it doesn't give errors, but obviously it is not doing what I need it to do, which is also give me the string after the needle.

so I will go with strpos(); (is suppose to be faster as well).

thanks

carsten888

11:46 am on Nov 21, 2007 (gmt 0)

10+ Year Member



besides that, it also gives the needle back, which is not what I want. so definately strpos().

thanks