Re: Problem with parameter count in strstr()
| From: | Shaun | Date: | Tue, 30 Nov 2004 20:25:28 +0000 |
| Subject: | Re: Problem with parameter count in strstr() | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-203178@lists.php.net to get a copy of this message | ||
Sorry,
I was confusing strstr with strtr!
"Matthew Weier O'Phinney" <matthew@garden.org> wrote in message
news:slrncqpivq.sgk.matthew@webmaster.garden.org...
>* Shaun <shaunthornburgh@hotmail.com>:
>> 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@garden.org
> Webmaster and IT Specialist | http://www.garden.org
> National Gardening Association |
> http://www.kidsgardening.com
> 802-863-5251 x156 |
> http://nationalgardenmonth.org