|
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]
|