You are here: preg_replace help « All PHP « IT news, forums, messages
preg_replace help

Posted by Wolverine on 04/25/06 16:08

Ok, here's my problem. I have this array of key->value pairs and
simply when I find a key I want to replace it with value. An example
of the array is as follows:

1->62
11->63
12->64
15->69
etc.

This is a list of corresponding user id's between two pieces of
software. I thought about using str_replace and creating an array of
all users but there are some sites that have 10k users and that would
be too expensive. So I am trying to use preg_replace to simply replace
any key with the value.

If $user_array is the aforementioned array, and $buffer is the subject,
is it possible to use a back reference in the replacement like this?

preg_replace( (\d+), $user_array['$1'], $buffer);

Or are there any ideas on what might be a better route to take?
Thanks!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация