Re: Problem with parameter count in strstr()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry,

I was confusing strstr with strtr!


"Matthew Weier O'Phinney" <matthew@xxxxxxxxxx> wrote in message 
news:slrncqpivq.sgk.matthew@xxxxxxxxxxxxxxxxxxxxxxx
>* Shaun <shaunthornburgh@xxxxxxxxxxx>:
>> I am trying to ensure that all data added to each element of 
>> $my_data_array
>> has no commas, however I get an error message saying Warning: Wrong
>> parameter count for strstr()
>>
>> $my_data_array[] =
>>           strstr( $data[1], ",", " " );
>>           strstr( $data[2], ",", " " ).', '.
>>           strstr( $data[3], ",", " " ).', '.
>>           strstr( $data[6], ",", " " ).', '.
>>           strstr( $data[13], ",", " " ).', '.
>>           strstr( $data[14], ",", " " ).', '.
>>           strstr( $data[15], ",", " " ).', '.
>>           strstr( $data[16], ",", " " ).', '.
>>           strstr( $data[17], ",", " " ).', '.
>>           strstr( $data[18], ",", " " ).', '.
>>           strstr( $data[19], ",", " " ).', '.
>>
>> Could someone tell me what I am doing wrong here please?
>
> A couple things:
>
> * Syntax for strstr() is strstr(string $haystack, string $needle) --
>  you're passing it three arguments instead of two
>
> * What exactly are you concatenating, and where do you expect it to go?
>  If you're trying to create a joined list of $data elements 1-19 and
>  assign it to a variable, you're going to run into issues when you get
>  to that semicolon at the end of your second line ;-)
>
> Also, if you're simply trying to do the following:
>
>    * Join a list of elements with a ,
>      * but only join the part of the element preceding a comma (or
>        space? not sure of your intentions as you've got bad arguments)
>
> Then you may want to try the following:
>
>    function subStr($n)
>    {
>        return strstr($n, ',');
>    }
>
>    $stripped = array_map('subStr', $data);
>    $my_data_array[] = join(', ', $stripped);
>
>
> -- 
> Matthew Weier O'Phinney           | mailto:matthew@xxxxxxxxxx
> Webmaster and IT Specialist       | http://www.garden.org
> National Gardening Association    | http://www.kidsgardening.com
> 802-863-5251 x156                 | http://nationalgardenmonth.org 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux