Re: [PHP] Arrays and Regs

2002-07-18 Thread Analysis & Solutions

Martin:

On Thu, Jul 18, 2002 at 03:55:13PM -0400, Martin Clifford wrote:
> 
> Just a performance question, if anyone knows for sure.  Within a large 
> array, would using numerical indices be quicker than associative?  I'm 
> talking about a *noticeable* difference in performance, here.

The difference is marginal.  The longer the variable name, the more 
resources used, but it's not something that you're really going to notice.  
More important is code readability.

But, the difference between turning line wrapping on (~77 columns) in your
email client will save significant time for people replying to your posts.


> $text = eregi_replace("([abc]+)", " red\">\\1", $text);
> 
> Would this replace any occurences of the pattern with the same pattern 
> match in red text?  I'm not sure exactly how the \\1, \\2, etc. works.

It matches sub-patterns, which are the things in parentheses.  The number 
corresponds to the parenthetical order.
  
> $text = eregi_replace("(a)(b)(c)", "\\1", $text);
> 
> Does this output only the 'a'?

Exactly.

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




[PHP] Arrays and Regs

2002-07-18 Thread Martin Clifford

Howdy,

Just a performance question, if anyone knows for sure.  Within a large array, would 
using numerical indices be quicker than associative?  I'm talking about a *noticeable* 
difference in performance, here.

Also, on Regular Expression replacements:

$text = eregi_replace("([abc]+)", "\\1", $text);

Would this replace any occurences of the pattern with the same pattern match in red 
text?  I'm not sure exactly how the \\1, \\2, etc. works.  So, does:

$text = eregi_replace("(a)(b)(c)", "\\1", $text);

Does this output only the 'a'?  I find this confusing for some reason, hehe.  Any help 
would be great!

Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/



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