RE: [PHP-GENERAL] Small problem with function..
| From: | Benton Jackson | Date: | Tue, 13 Jun 2000 02:26:50 +0000 |
| Subject: | RE: [PHP-GENERAL] Small problem with function.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1679@lists.php.net to get a copy of this message | ||
What's it supposed to do? Delete all the $chars in $string?
You forgot the "$" in front of some of the "pos", that's one thing wrong.
> From: Sylwester Zarębski [mailto:sylwek@isp.net.pl]
>
> Hi!
>
>
> I have problem with small function. This function doesn't work
> as expected, and consume all available memory and kills apache
> server. Here goes my function:
>
> function strdelc ( $string, $chars ) {
> $chars_len = strlen ( $chars );
> for ( $cnt = 0; $cnt < $chars_len; ++$cnt ) {
> $char = substr ( $chars, $cnt, 1 );
> while ( ( $pos = strpos ( $string, $char ) ) || is_int ( $pos ) ) {
> if ( $pos == 0 ) {
> $string = substr ( $string, pos + 1 );
> } elseif ( $pos < strlen ( $string ) - 1 ) {
> $string = substr ( $string, 0, $pos - 1 ) . substr
> $string, pos
> + 1 );
> } else {
> $string = substr ( $string, 0, $pos - 1 );
> }
> }
> }
> return ( $string );
> }
>
> Is this any problem with text assignment ???
> Or where is my fault ?? Please help..
>
> --
> pozdrawiam..
>
> ## ## | Sylwester Zarębski - ISP Group |
> #### ## | e-mail: sylwek@isp.net.pl |
> ## ## ## | ICQ uin: #45780888 |
> ## #### ## | Administrator ISP.NET.PL |
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net