Re: [PHP-DEV] string replacement

2001-01-22 Thread Andrei Zmievski

Done.

On Mon, 22 Jan 2001, Martin Jansen wrote:
> On Mon, 22 Jan 2001 16:28:09 +0100 (CET), Derick Rethans wrote:
> 
> >On Mon, 22 Jan 2001, Andrei Zmievski wrote:
> >> I could modify str_replace() to have the same behavior with regard to
> >> arrays as preg_replace() - if people agree that it's a good idea..
> >
> >I think it's a good idea, makes the language more consistent.
> 
> +1
> 
> -Martin
> 
> 
> -- 
> PHP Development Mailing List 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 



-Andrei

"The secret of flying is to throw yourself
at the ground, and miss." -- Douglas Adams

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] string replacement

2001-01-22 Thread Martin Jansen

On Mon, 22 Jan 2001 16:28:09 +0100 (CET), Derick Rethans wrote:

>On Mon, 22 Jan 2001, Andrei Zmievski wrote:
>> I could modify str_replace() to have the same behavior with regard to
>> arrays as preg_replace() - if people agree that it's a good idea..
>
>I think it's a good idea, makes the language more consistent.

+1

-Martin


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] string replacement

2001-01-22 Thread Derick Rethans

On Mon, 22 Jan 2001, Andrei Zmievski wrote:

> On Mon, 22 Jan 2001, Jan Borsodi wrote:
> > So I ask again:
> > Are there any plans to make str_replace and ereg_replace take arrays
> > as parameters as well, in the same manner as preg_replace does?
> > (a simple yes or no will suffice)
> >
> > Or do I have to do this myself?
>
> I could modify str_replace() to have the same behavior with regard to
> arrays as preg_replace() - if people agree that it's a good idea..
>
> -Andrei
> * I don't have a solution but I admire the problem. *
>
> --
> PHP Development Mailing List 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

I think it's a good idea, makes the language more consistent.

Derick Rethans

-
  PHP: Scripting the Web - www.php.net - [EMAIL PROTECTED]
-
JDI Media Solutions - www.jdimedia.nl - [EMAIL PROTECTED]
 H.v. Tussenbroekstraat 1 - 6952 BL Dieren - The Netherlands
-


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] string replacement

2001-01-22 Thread Andrei Zmievski

On Mon, 22 Jan 2001, Jan Borsodi wrote:
> So I ask again:
> Are there any plans to make str_replace and ereg_replace take arrays
> as parameters as well, in the same manner as preg_replace does?
> (a simple yes or no will suffice)
> 
> Or do I have to do this myself?

I could modify str_replace() to have the same behavior with regard to
arrays as preg_replace() - if people agree that it's a good idea..

-Andrei
* I don't have a solution but I admire the problem. *

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] string replacement

2001-01-22 Thread Jan Borsodi

Cynic <[EMAIL PROTECTED]> writes:

> so it's probably not str_replace what's slowing you down, but 
> the loops? Maybe they could be optimized some more... (I don't 
> want it sound like I'm saying it's your fault, or that you're 
> a bad programmer, just to make it clear.)

No it's not the loops it's just PHP being as slow as it always is.

The loop looks something like this:
$str = "lots of text";
$arr = array( "a", "b", "c", "d" );
$vals = array( "e", "f", "g", "h" );
$a =& each( $arr );
$b =& each( $vals );
while( $a && $b )
{
str =& str_replace( $a[1], $b[1], $str );
$a =& each( $arr );
$b =& each( $vals );
}

Anyways this is beyond the point which is that these three functions
(str_replace, ereg_replace and preg_replace) does the same things but
varying complexity, but their usage is not the same. This is just a
matter of consistency amongst functions.
When I want to replace a simple string with another string I use
str_replace, when I want to replace a regular expression with a string
I use ereg_replace or preg_replace. However when I want replace lots
of simple strings I must use preg_replace due to speed. This is not
good.

So I ask again:
Are there any plans to make str_replace and ereg_replace take arrays
as parameters as well, in the same manner as preg_replace does?
(a simple yes or no will suffice)

Or do I have to do this myself?

-- 
- Jan Borsodi <[EMAIL PROTECTED]> - Systems Engineer @ eZ systems - Web: http://ez.no
  QtVu: http://www.qtvu.org  -  RegExplorer: http://regexplorer.sourceforge.net
  EMacro: http://emacro.sourceforge.net  -  Apollo: http://www.apolloplayer.org

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] string replacement

2001-01-21 Thread Jan Borsodi

Cynic <[EMAIL PROTECTED]> writes:

> why is it bad?

Why?
Because it's quite normal for functions like str_replace to be *much*
faster than preg_replace, but since str_replace on arrays is slower
(due to iterating over them using PHP code) you have to use preg_replace.

I'll happily use preg_replace whenever I need to do some Regular
Expression replacement, but when I want to do normal text replacement
I expect str_replace to give me the same flexibility as preg_replace.

That's why!

-- 
- Jan Borsodi <[EMAIL PROTECTED]> - Systems Engineer @ eZ systems - Web: http://ez.no
  QtVu: http://www.qtvu.org  -  RegExplorer: http://regexplorer.sourceforge.net
  EMacro: http://emacro.sourceforge.net  -  Apollo: http://www.apolloplayer.org

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] string replacement

2001-01-21 Thread Cynic

why is it bad?

At 19:45 21.1. 2001, Jan Borsodi wrote the following:
-- 
>Is there any plans to extend str_replace and ereg_replace to accept
>arrays in the same manner as preg_replace does?
>
>At the moment using preg_replace on arrays are faster than iterating
>trough the arrays and passing them to str_replace, which is bad.
>
>-- 
>- Jan Borsodi <[EMAIL PROTECTED]> - Systems Engineer @ eZ systems - Web: http://ez.no
>  QtVu: http://www.qtvu.org  -  RegExplorer: http://regexplorer.sourceforge.net
>  EMacro: http://emacro.sourceforge.net  -  Apollo: http://www.apolloplayer.org
>
>-- 
>PHP Development Mailing List 
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
--end of quote-- 




Cynic:

A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.

[EMAIL PROTECTED]



-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]