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 <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to