Hi Everyone,
A newbie here - but looking for some help to something that is killing my brain :).
What I want to do is to do a string replacement through one array(multi-dimensional) using values from another.
Here is what I have:
$regex = '/\{(.*?)}/i';
$options = array('username'=>'mjoe',
'maxage'=>'30',
'minage'=>'20'
);
$criteria = array('username' => '{username}',
'age'=>array('$lt' => '{maxage}','$gte' => '{minage}'),
);
What I want to end up with is the following:
$newarray = array('username' => 'mjoe',
'age'=>array('$lt' => '30','$gte' => '20'),
);
Basically replacing anything in the { } with the actual values from options.
Anyone have ideas on the best way to accomplish this? I have looked through all the php functions for str_replace but I am wondering if there is any easy way like using array_merge or something like that?
Any ideas would be greatly appreciated.
Thanks,
K
Merging two arrays(one multi dimensional) using a Regex & string replacement
Started by kidder, Jun 28 2010 07:42 AM
1 reply to this topic


Sign In
Create Account

Back to top









